internal class BaseItemVO { public string name; public string lockA; }
public static void setValue(Object tar, String name, Object value) { FieldInfo fInfo = tar.GetType().GetField(name); Type type = fInfo.FieldType; if (type==typeof(String)) { //这里能够VO中获取字段的类型 Console.WriteLine("this is a string"); } fInfo.SetValue(tar, value); //设置VO中的字段的值 }
代码虽然一点点,在读取xml配置的时候很是有用,简单记录一下。this