What Does System.Double[*] Mean

Can't access/convert System.Double[*] object

You must do this:

var dataSetValues = dataSet.DoubleArray; // dataSetValues is dynamic
var result = ConvertDoubleArray((Array)(object)dataSetValues);

The reason is the 'dynamic' type of the DoubleArray (that was probably automatically defined in the interface when you added the COM reference). It's a super smart thing that tries to do the conversion from System.Double[*] to System.Double[] by itself, but it's not smart enough to do this (it can't read StackOverflow answers... yet)

So, you'll have to ask it to just pass the object 'as is', to be able to pass it directly to the CLR low-level cast, which can do System.Double[*] to Array w/o crashing. Once you have the Array, you can re-use the ConvertDoubleArray utility.

Is there a meaningful difference between Double and double in .Net?

There is no difference. double is just an alias for System.Double in C#.

Note that VB.NET doesn't have the same aliasing (int for System.Int32, double for System.Double, etc), so the aliasing is just applicable to C#, not .NET as a whole.

When is a System.Double not a double?

By far the best source you can get for .NET assemblies is the actual source code that was used to build them. Beats any decompiler for accuracy, the comments can be quite useful as well. Download the Reference Source.

You'll then also see that Double.NaN isn't defined in IL as Marc assumed, it's actually in a C# source code file. The net/clr/bcl/system/double.cs source code file shows the real declaration:

  public const double NaN = (double)0.0 / (double)0.0;

Which takes advantage of the C# compiler evaluating constant expressions at compile time. Or to put it tongue-in-cheek, NaN is defined by the C++ compiler since that's the language that was used to write the C# compiler ;)

What are these asterisks when I generate a constructor with 2D arrays as parameters in Visual Studio?

    int[*, *] property1

This is caused by a Visual Studio bug. The odd-looking syntax matches the appearance of a non-conformant array. An array is conformant, and its syntax supported by C#, when its lower bounds are 0. C# has no syntax available for array types that are not conformant, thus the weirdo [*,*] and the compile errors it generates.

This normally only happens in C# when you interop with a foreign type system that is capable of creating such array types. I only know of COM as a practical example that is capable of emitting type info that can be directly consumed by a C# program. Note the syntax match in this existing question, another one here.

But of course the type of your property is not special. VS is losing its marbles in the Roslyn code integrated in the IDE. The team that works on this does not have a good track record of writing bug-free tested code. I cannot get a repro for this myself, I'm on version 15.5.6 and have avoided updating to 15.6.x due to the large number of bug reports it has generated. Minor odds that it is specific to the Mac edition, the OS is COM-challenged. VS2015 did not yet have this feature, which is why you can't find it, ReSharper is a popular commercial alternative.

Inside VS use Help > Send Feedback > Report a Problem to tell them about the bug. I don't see an existing bug report for this defect, at least no match when searching developercommunity.visualstudio.com for "generate constructor". I don't expect many programmers running into this bug or taking the time to report it. The workaround is simple, just edit the code to int[,] property1.

What does System.String[*] represent?

From MSDN

Type.GetType("MyArray[*]") gets a single-dimension array with unknown lower bound

System.Windows.Media.Matrix does not use System.Double precision 64-bit number?

The matrix class DOES use doubles. You can check the source code here.

public double Determinant
{
get
{
switch (_type)
{
case MatrixTypes.TRANSFORM_IS_IDENTITY:
case MatrixTypes.TRANSFORM_IS_TRANSLATION:
return 1.0;
case MatrixTypes.TRANSFORM_IS_SCALING:
case MatrixTypes.TRANSFORM_IS_SCALING | MatrixTypes.TRANSFORM_IS_TRANSLATION:
return(_m11 * _m22);
default:
return(_m11 * _m22) - (_m12 * _m21);
}
}
}

(where _m11 etc are all double)

The following code prints "Same results!", indicating that there is no difference between your calculation and Matrix.Determinant:

using System;

namespace Demo
{
class Program
{
static void Main()
{
double m11 = 0.00000001, // 1E-08
m12 = 0,
m21 = 0,
m22 = 0.0000001; // 1E-07

double det = m11 * m22 - m12 * m21;
Console.WriteLine(det);

var mat = new System.Windows.Media.Matrix(m11, m12, m21, m22, 0, 0);
Console.WriteLine(mat.Determinant);

if (mat.Determinant == det)
Console.WriteLine("Same results!"); // This is printed.

Console.WriteLine(mat.HasInverse); // Has no inverse, though.
}
}
}

The answer as to why it says there is no inverse can be found by looking at the implementation of HasInverse:

public bool HasInverse
{
get
{
return !DoubleUtil.IsZero(Determinant);
}
}

Where DoubleUtil.IsZero() is implemented thusly (I have simplified this to make it more obvious what's happening):

public static bool IsZero(double value)
{
return Math.Abs(value) < 2.22044604925031E-15;
}

In this case, value is 1E-15 which is less than 2.22044604925031E-15 so DoubleUtil.IsZero() returns true and hence Matrix.HasInverse returns false.



Related Topics



Leave a reply



Submit