本文整理匯總了C#中System.Type.IsClass屬性的典型用法代碼示例。如果您正苦於以下問題:C# Type.IsClass屬性的具體用法?C# Type.IsClass怎麽用?C# Type.IsClass使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Type
的用法示例。
在下文中一共展示了Type.IsClass屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Reflection;
public class MyDemoClass
{
}
public class MyTypeClass
{
public static void Main(string[] args)
{
try
{
Type myType = typeof(MyDemoClass);
// Get and display the 'IsClass' property of the 'MyDemoClass' instance.
Console.WriteLine("\nIs the specified type a class? {0}.", myType.IsClass);
}
catch(Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);
}
}
}
示例2: MethodA
//引入命名空間
using System;
using System.Reflection;
public interface IFaceOne
{
void MethodA();
}
public interface IFaceTwo
{
void MethodB();
}
public class MyClass: IFaceOne, IFaceTwo
{
public enum MyNestedEnum{}
public int myIntField;
public string myStringField;
public void myMethod(int p1, string p2)
{
}
public int MyProp
{
get { return myIntField; }
set { myIntField = value; }
}
void IFaceOne.MethodA(){}
void IFaceTwo.MethodB(){}
}
public class MainClass
{
public static void Main(string[] args)
{
MyClass f = new MyClass();
Type t = f.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);
}
}