Hi All,
The question is regarding Unmanaged and Managed code conversion in C# for structures.
I have two structures like:
public struct Detail
{
public int age;
public string address;
public Detail(int _age, string _address)
{
age = _age;
address = _address;
}
}
public struct Name
{
public Detail[] names;
}
While passing the code to StructureToPtr function:
Name some = new Name();
some.names[0].age = 23;
some.names[0].address = "123,ABC Farms";
int Size = Marshal.SizeOf(some);
IntPtr data = Marchal.AllocHGlobal(Size);
Marshal.StructureToPtr(some, data, true);
This code is showing error as Parameters are not correct, and if i tried to pass the same code without using array, it worked perfectly.
Can anyone please suggest me what should i try to resolve the problem.