Get type infomation: base type, is abstract, is com object, is sealed, is class
using System;
using System.Reflection;
public class Test
{
public static void Main(string[] args)
{
TheType.MyClass aClass = new TheType.MyClass();
Type t = aClass.GetType();
Console.WriteLine("Full name is: {0}", t.FullName);
Console.WriteLine("Base is: {0}", t.BaseType);
Console.WriteLine("Is it abstract? {0}", t.IsAbstract);
Console.WriteLine("Is it a COM object? {0}", t.IsCOMObject);
Console.WriteLine("Is it sealed? {0}", t.IsSealed);
Console.WriteLine("Is it a class? {0}", t.IsClass);
}
}
namespace TheType {
public interface IFaceOne {
void MethodA();
}
public interface IFaceTwo {
void MethodB();
}
public class MyClass: IFaceOne, IFaceTwo {
public int myIntField;
public string myStringField;
private double myDoubleField = 0;
public double getMyDouble(){
return myDoubleField;
}
public void myMethod(int p1, string p2)
{
}
public int MyProp
{
get { return myIntField; }
set { myIntField = value; }
}
public void MethodA() {}
public void MethodB() {}
}
}
Related examples in the same category