Hello,
How can I define fixed size of structure in c#..
e.g.
struct xyz{
char localc[12];
short localshort;
};
I had made a c# structure like this
[StructLayout(LayoutKind.Sequential, Pack = 2,CharSet=CharSet.Ansi, Size = 14)]
struct xyz{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public char[] localc;
short localshort;
}
xyz abc = new xyz();
Here i am not able to get the sizeof abc as 14 ..and got error while mashal.sizeof(abc);
How should i preallocate memory of size of structure ?
I can easily does that in c/c++ by just declaring it .. how to make this possible in c#?
and i can initialise the structure using memset in c .. whats its alternative in c#?
It will be helpful to get the solution