通过反射,可以获取所有声明的成员变量(包括所有的),代码如下: package spt.test.src; public class Person { private String name = "pri_name"; public String id; } 运行测试: package spt.test; import java.lang.reflect.Field; import spt.test.src.Person; class ReflectionTest { @Suppres
给方法打自定义标签再反射获取 1.自定义特性类 using System; using System.Collections; using System.Collections.Generic; /// <summary> /// 自定义新特性 /// </summary> [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public class CustomA