Why can't I use Marshal.SizeOf() to calculate the size of an instance of type ValueTuple?

540 Views Asked by At

Why does the following code:

   ValueTuple<double, double> origin = (0.0, 0.0);

   Console.WriteLine($"Size of ValueTuple<double, double>: {Marshal.SizeOf(origin)}");

throw System.ArgumentException: 'Type 'System.ValueTuple`2[System.Double,System.Double]' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.'

0

There are 0 best solutions below