求教如题!

解决方案 »

  1.   

    简单,加static是静态的,不加static是非静态的
      

  2.   

    方法不是很好,但可用
    public static void CanMakeInstance(Type t)
    {
        try
        {
            Activator.CreateInstance(t);
            Console.WriteLine("非静态类");
        }
        catch
        {
            Console.WriteLine("静态类");
        }
    }
      

  3.   

                Type t=typeof(class1);
                System.Reflection.TypeAttributes ta = t.Attributes;
                string s = ta.ToString();
                if (s.Contains("Abstract") && s.Contains("Sealed"))
                {
                    Console.WriteLine("static class");
                }
      

  4.   


    获取类的全名 判断有没有static class 嗯 嗯
      

  5.   

    反射!不解释哈哈~~~~突然想到一个笨办法嘿嘿:try实例化某类,如果catch到异常就不是静态类否则为静态滴~~~~~~哈哈也算是一种思路
    但是正式用还是用反射吧:
               Type t=typeof(class1);
                System.Reflection.TypeAttributes ta = t.Attributes;
                string s = ta.ToString();
                if (s.Contains("Abstract") && s.Contains("Sealed"))
                {
                    Console.WriteLine("static class");
                }
      

  6.   

    使用reflector看看il中静态类和非静态静态类在定义上添加了那些标示.然后使用反射判断.
      

  7.   

    typeof(ABC).IsSealed && typeof(ABC).IsAbstract
      

  8.   

    C# code
    public static void CanMakeInstance(Type t)
    {
    try
    {
    Activator.CreateInstance(t);
    Console.WriteLine("非静态类");
    }
    catch
    {
    Console.WriteLine……
      

  9.   

    我晕。。是不是静态一看就知道了有 static的就是