Reputation: 967
string s = "hello";
Console.WriteLine(Marshal.SizeOf(s)); // gives error
Marshal.Sizeof works for other data-types like int, char etc. but does not works for string datatype. Any specific reason for this?
Upvotes: 1
Views: 771
Reputation: 100547
String is reference type (class
) not value type (struct
).
This method accepts an instance of a structure, which can be a reference type or a boxed value type. The layout must be sequential or explicit.
Upvotes: 5