typeof a Class name : Typeof : Operator C# Examples


C# Examples » Operator » Typeof »

 

typeof a Class name









    
using  System;
using  System.IO;

class  MainClass
{
        public  static  void  Main()  
        {
                Object  someObject  =  new  StringReader("This  is  a  StringReader");

                if  (typeof(StringReader)  ==  someObject.GetType())  
                {
                        Console.WriteLine("typeof:  someObject  is  a  StringReader");
                }

        }
}
    
   
  
   



Output

typeof: someObject is a StringReader


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Operator
» Typeof