Invoke internal field
Hvordan invoker jeg dynamisk min klasses internal fields jf nedenstående eksempel?internal class MyClass{
internal string
MyField = "my text";
public override string ToString(){
Type type = GetType();
FieldInfo[] fields = type.GetFields();
for(int i=0; i<fields.Length; i++){
FieldInfo field = fields[i];
Console.Write("{0}={1}", field.Name, field.GetValue(this));
}
return sb.ToString();
}
}