S
Sharon
Hello Gurus,
I have a class:
[StructLayout(LayoutKind.Sequential)]
public class Madads
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] MAD = new char[8];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)]
public char[] NAME = new char[31];
public Madads() {}
}
Assuming there may be more fields and not all of them of type char[].
I want to add some code to class constructor, using reflection, to
initialize all its char members with ‘ ‘ (space) value.
I did this:
Type thisType = this.GetType();
System.Reflection.FieldInfo [] fieldsInfo = thisType.GetFields();
string str;
foreach( System.Reflection.FieldInfo fi in fieldsInfo )
{}
But I can see where to go from there.
How do I go from there?
I have a class:
[StructLayout(LayoutKind.Sequential)]
public class Madads
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] MAD = new char[8];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)]
public char[] NAME = new char[31];
public Madads() {}
}
Assuming there may be more fields and not all of them of type char[].
I want to add some code to class constructor, using reflection, to
initialize all its char members with ‘ ‘ (space) value.
I did this:
Type thisType = this.GetType();
System.Reflection.FieldInfo [] fieldsInfo = thisType.GetFields();
string str;
foreach( System.Reflection.FieldInfo fi in fieldsInfo )
{}
But I can see where to go from there.
How do I go from there?