CSharp examples for Reflection:Member
Get member information via reflection
using System;//w ww. java 2 s . c o m using System.Reflection; class MyMemberInfo { int classMyValue; public void THIS_IS_A_METHOD() { } public int MyValue // property { set { classMyValue = value; } } public static int Main() { string testclass = "Reflect.MyMemberInfo"; Console.WriteLine ("\nFollowing is the member info for class: {0}", testclass ); Type MyType = Type.GetType(testclass); MemberInfo[] MyMemberInfoArray = MyType.GetMembers(); Console.WriteLine("\nThere are {0} members in {1}", MyMemberInfoArray.GetLength(0), MyType.FullName); for ( int counter = 0;counter < MyMemberInfoArray.GetLength(0);counter++ ) { Console.WriteLine( "{0}. {1} Member type - {2}",counter,MyMemberInfoArray[counter].Name,MyMemberInfoArray[counter].MemberType.ToString()); } return 0; } }