C# type - IsPrimitive

 

            Type t = typeof(string);
            if (t.IsPrimitive)//not 
            {
                Console.WriteLine("string is a Primitive");
            }
            else 
            {
                Console.WriteLine("string is not a Primitive");
            }

            Type t2 = typeof(String);
            if (t2.IsPrimitive)//not 
            {
                Console.WriteLine("String is a Primitive");
            }
            else
            {
                Console.WriteLine("String is not a Primitive");
            }

            Type t3 = typeof(int);
            if (t3.IsPrimitive)//yes 
            {
                Console.WriteLine("int is a Primitive");
            }
            else
            {
                Console.WriteLine("int is not a Primitive");
            }


            Type t4 = typeof(Int64);
            if (t4.IsPrimitive)//yes
            {
                Console.WriteLine("Int64 is a Primitive");
            }
            else
            {
                Console.WriteLine("Int64 is not a Primitive");
            }

 

posted @ 2014-07-03 09:45  vivianC  阅读(1553)  评论(0编辑  收藏  举报