Demonstrate typeof : typeof « Operator « C# / CSharp Tutorial






using System; 
using System.IO; 
 
class MainClass { 
  public static void Main() { 
    Type t = typeof(StreamReader); 
 
    Console.WriteLine(t.FullName);     
 
    if(t.IsClass) 
         Console.WriteLine("Is a class."); 
    if(t.IsAbstract) 
         Console.WriteLine("Is abstract."); 
    else 
         Console.WriteLine("Is concrete."); 
 
  } 
}
System.IO.StreamReader
Is a class.
Is concrete.








3.16.typeof
3.16.1.Using typeof
3.16.2.Demonstrate typeof
3.16.3.typeof a Class name
3.16.4.Using typeof operator in if statement
3.16.5.Obtain type information using the typeof operator
3.16.6.Assign returning value from 'Typeof Operator' to 'Type' variable