using System;
using System.Reflection;
class ReflectionTest {
public static void TypeofExam() {
Type t = typeof(byte);
FieldInfo[] fi = t.GetFields();
MethodInfo[] mi = t.GetMethods();
foreach(FieldInfo f in fi) {
Console.WriteLine("Field : {0}", f);
}
foreach(MethodInfo m in mi) {
Console.WriteLine("Method : {0}", m);
}
}
public static void GetTypeExam() {
ReflectionTest r = new ReflectionTest();
Type t = r.GetType();
FieldInfo[] fi = t.GetFields();
MethodInfo[] mi = t.GetMethods();
foreach(FieldInfo f in fi) {
Console.WriteLine("Field : {0}", f);
}
foreach(MethodInfo m in mi) {
Console.WriteLine("Method : {0}", m);
}
}
static void Main() {
TypeofExam();
Console.WriteLine("-------------------------");
GetTypeExam();
}
}
[결과]
Field : Byte MaxValue
Field : Byte MinValue
Method : System.String ToString(System.IFormatProvider)
Method : System.TypeCode GetTypeCode()
Method : System.String ToString(System.String, System.IFormatProvider)
Method : Int32 CompareTo(System.Object)
Method : Int32 GetHashCode()
Method : Boolean Equals(System.Object)
Method : System.String ToString()
Method : Byte Parse(System.String)
Method : Byte Parse(System.String, System.Globalization.NumberStyles)
Method : Byte Parse(System.String, System.IFormatProvider)
Method : Byte Parse(System.String, System.Globalization.NumberStyles, System.IFo
rmatProvider)
Method : System.String ToString(System.String)
Method : System.Type GetType()
-------------------------
Method : Int32 GetHashCode()
Method : Boolean Equals(System.Object)
Method : System.String ToString()
Method : Void TypeofExam()
Method : Void GetTypeExam()
Method : System.Type GetType()
댓글 없음:
댓글 쓰기