Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0148 is operator

is operator tells if a reference is a certain class. using System; class Person { public string name; } class Employee : Person { public string companyName; } class Program { static void Main(string[] args) { Person p = new Employee(); Console.WriteLine(p is Employee); } } The output: True