本文整理汇总了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);
}
}