How to "is" Keyword Using in C#

  1. using System;  
  2. class BaseClass  
  3. {}  
  4. class DerivedClass: BaseClass  
  5. {}  
  6. class isKeywordUsing  
  7. {  
  8.     public static void Main()  
  9.     {  
  10.         BaseClass baseObject = new BaseClass();  
  11.         DerivedClass derivedObject = new DerivedClass();  
  12.         Console.WriteLine("baseObject is BaseClass Type: {0}", baseObject is BaseClass);  
  13.         Console.WriteLine("derivedObject is DerivedClass Type: {0}", derivedObject is DerivedClass);  
  14.         Console.WriteLine("baseObject is DerivedClass Type: {0}", baseObject is DerivedClass);  
  15.         Console.WriteLine("\nderivedObject is BaseClass Type: {0}", derivedObject is BaseClass);  
  16.     }  
  17. }  
Answer:

baseObject is BaseClass Type: True
derivedObject is DerivedClass Type: True
baseObject is DerivedClass Type: False
derivedObject is BaseClass Type: True