G
Guest
All,
Can anyone supply an example or reference to an example of using
reflection to determine the data types and array lengths contained in a
nested stucture in C#? Actually, it is a structure that I use to communicate
to some unmanaged code in a DLL written in C. It is not complicated, but will
change and I would like to be able to sequentially access it without
explicitly referring to each and every element. Here is the structure:
[StructLayout(LayoutKind.Sequential)]
unsafe public struct MyOutputs
{
[StructLayout(LayoutKind.Sequential)]
unsafe public struct TelemListA
{
public double navTime;
public double navMode;
public Outputs outputs;
}
[StructLayout(LayoutKind.Sequential)]
unsafe public struct Outputs
{
public fixed double Q_isa[4];
public fixed double dV[3];
public fixed double dT[3];
public fixed double Q_mid[4];
}
}
Once I get the list of MemberInfo[] and determine that
MemberInfo.MemberType.ToString().Equals("NestedType"), I cannot
figure out how to drill down from that point.
TIA,
Bill
Can anyone supply an example or reference to an example of using
reflection to determine the data types and array lengths contained in a
nested stucture in C#? Actually, it is a structure that I use to communicate
to some unmanaged code in a DLL written in C. It is not complicated, but will
change and I would like to be able to sequentially access it without
explicitly referring to each and every element. Here is the structure:
[StructLayout(LayoutKind.Sequential)]
unsafe public struct MyOutputs
{
[StructLayout(LayoutKind.Sequential)]
unsafe public struct TelemListA
{
public double navTime;
public double navMode;
public Outputs outputs;
}
[StructLayout(LayoutKind.Sequential)]
unsafe public struct Outputs
{
public fixed double Q_isa[4];
public fixed double dV[3];
public fixed double dT[3];
public fixed double Q_mid[4];
}
}
Once I get the list of MemberInfo[] and determine that
MemberInfo.MemberType.ToString().Equals("NestedType"), I cannot
figure out how to drill down from that point.
TIA,
Bill