- using System;
- class BaseClass
- {}
- class DerivedClass: BaseClass
- {}
- class isKeywordUsing
- {
- public static void Main()
- {
- BaseClass baseObject = new BaseClass();
- DerivedClass derivedObject = new DerivedClass();
- Console.WriteLine("baseObject is BaseClass Type: {0}", baseObject is BaseClass);
- Console.WriteLine("derivedObject is DerivedClass Type: {0}", derivedObject is DerivedClass);
- Console.WriteLine("baseObject is DerivedClass Type: {0}", baseObject is DerivedClass);
- Console.WriteLine("\nderivedObject is BaseClass Type: {0}", derivedObject is BaseClass);
- }
- }
Answer:
baseObject is BaseClass Type: True
derivedObject is DerivedClass Type: True
baseObject is DerivedClass Type: False
derivedObject is BaseClass Type: True