hi,
I need to implement C++ types in c#. Here's my code.
[StructLayout(LayoutKind.Sequential)]
public struct tdUMSFuncValue
{
//[FieldOffset(0)]
[MarshalAs(UnmanagedType.LPTStr)]
public string szName;
//[FieldOffset(2)]
public tdUMSFuncType ft;
//[FieldOffset(4)]
public double dfloat;
//[FieldOffset(6)]
public int lInteger;
//[FieldOffset(8)]
public Int64 time_t;
//[FieldOffset(10)]
[MarshalAs(UnmanagedType.LPTStr)]
public string szString;
}
[StructLayout(LayoutKind.Sequential)]
public struct tdUMSFuncValues
{
public tdUMSFuncValue[] fv;
public int lCt;
public tdUMSFuncValues()
{
tdUMSFuncValue[] fv = new tdUMSFuncValue[11];
fv[0] = new tdUMSFuncValue();
lCt = 0;
}
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Premal MehtaPosted Jun 23, 2016, 1:58 PM
the c++ code has this struct.
long lCt; // Number of actual values: 1 to 11
tdUMSFuncValue fv[11]; // Values
} tdUMSFuncValues;
I am trying to recreate this in C# ? how can this be achieved ?
Karthik ElumalaiPosted Jun 23, 2016, 11:18 AM
Struct constructors are similar to class constructors, except for the following differences: