using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace Reflection { class Program { static void Main(string[] args) { string s = "Hello Reflection"; Type t = s.GetType(); Console.WriteLine(t.FullName); Type t2 = Type.GetType("System.String",false,true); Console.WriteLine(t2.FullName); Type t3 = typeof(string); Console.WriteLine(t3.FullName); // GetMehtods(t); Console.WriteLine("Join method:{0}",t.GetMethod("Copy")); GetMehtods(t,BindingFlags.Public|BindingFlags.Instance); //GetFields().GetProperites() Console.ReadLine(); } public static void GetMehtods(Type t,BindingFlags f) { MethodInfo[] mi = t.GetMethods(f); foreach (MethodInfo m in mi) { Console.WriteLine("{0}",m.Name); } } } }
时间: 2024-10-29 21:52:53