Hello,
i have a problem look at the following code:
public class FieldInfoClass
{
//This is the member from which I want to get the Type (I want 'int' not 'System.Array')
public int[] myIntArray = new int[0];
public static void Main()
{
object o = new FieldInfoClass();
Type myType = typeof(FieldInfoClass);
// Get the type and fields of FieldInfoClass.
FieldInfo[] myFieldInfo = myType.GetFields();
//There is only one Field in the FieldInfoClass!
FieldInfo fi = myFieldInfo[0];
Type type1 = fi.FieldType;
Debug.Print("type1: " + type1.ToString());
//Output:
//type1: System.Array
//But I want the type 'Int32'!!!
object p = fi.GetValue(o);
Type type2 = p.GetType();
Debug.Print("type2: " + type2.ToString());
//Output:
//type2: System.Int32[]
//But I want the type 'Int32'!!!
//My problem is that FieldInfoClass is a class where the members have no value at this time!
//They should get a value and because of this I want to know the type of the array.
}
}
Has someone a idea how I can get out the type of the array?
i have a problem look at the following code:
public class FieldInfoClass
{
//This is the member from which I want to get the Type (I want 'int' not 'System.Array')
public int[] myIntArray = new int[0];
public static void Main()
{
object o = new FieldInfoClass();
Type myType = typeof(FieldInfoClass);
// Get the type and fields of FieldInfoClass.
FieldInfo[] myFieldInfo = myType.GetFields();
//There is only one Field in the FieldInfoClass!
FieldInfo fi = myFieldInfo[0];
Type type1 = fi.FieldType;
Debug.Print("type1: " + type1.ToString());
//Output:
//type1: System.Array
//But I want the type 'Int32'!!!
object p = fi.GetValue(o);
Type type2 = p.GetType();
Debug.Print("type2: " + type2.ToString());
//Output:
//type2: System.Int32[]
//But I want the type 'Int32'!!!
//My problem is that FieldInfoClass is a class where the members have no value at this time!
//They should get a value and because of this I want to know the type of the array.
}
}
Has someone a idea how I can get out the type of the array?