Is vs As operator keyword in C# Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The difference between is and as operators are as follows: The is operator is used to check if the run-time type of an object is compatible with the given type or not whereas as operator is used to perform conversion between compatible reference types or Nullable types. The is operator is of boolean type whereas as operator is not of boolean type. The is operator returns true if the given object is of the same type whereas as operator returns the object when they are compatible with the given type. The is operator returns false if the given object is not of the same type whereas as operator return null if the conversion is not possible. The is operator is used for only reference, boxing, and unboxing conversions whereas as operator is used only for nullable, reference and boxing conversions Example of is operator: CSharp // C# program to illustrate the // use of is operator keyword using System; // taking a class public class P { } // taking a class // derived from P public class P1 : P { } // taking a class public class P2 { } // Driver Class public class GFG { // Main Method public static void Main() { // creating an instance // of class P P o1 = new P(); // creating an instance // of class P1 P1 o2 = new P1(); // checking whether 'o1' // is of type 'P' Console.WriteLine(o1 is P); // checking whether 'o1' is // of type Object class // (Base class for all classes) Console.WriteLine(o1 is Object); // checking whether 'o2' // is of type 'P1' Console.WriteLine(o2 is P1); // checking whether 'o2' is // of type Object class // (Base class for all classes) Console.WriteLine(o2 is Object); // checking whether 'o2' // is of type 'P' // it will return true as P1 // is derived from P Console.WriteLine(o2 is P1); // checking whether o1 // is of type P2 // it will return false Console.WriteLine(o1 is P2); // checking whether o2 // is of type P2 // it will return false Console.WriteLine(o2 is P2); } } Output: True True True True True False False Example of as operator: CSharp // C# program to illustrate the // concept of 'as' operator using System; // Classes class Y { } class Z { } class GFG { // Main method static void Main() { // creating and initializing object array object[] o = new object[5]; o[0] = new Y(); o[1] = new Z(); o[2] = "Hello"; o[3] = 4759.0; o[4] = null; for (int q = 0; q < o.Length; ++q) { // using as operator string str1 = o[q] as string; Console.Write("{0}:", q); // checking for the result if (str1 != null) { Console.WriteLine("'" + str1 + "'"); } else { Console.WriteLine("Is is not a string"); } } } } Output: 0:Is is not a string 1:Is is not a string 2:'Hello' 3:Is is not a string 4:Is is not a string Comment More info A ankita_saini Follow Improve Article Tags : C# CSharp-keyword Explore IntroductionC# Tutorial 4 min read Introduction to .NET Framework 6 min read C# .NET Framework (Basic Architecture and Component Stack) 6 min read C# Hello World 2 min read Common Language Runtime (CLR) in C# 4 min read FundamentalsC# Identifiers 2 min read Data Types in C# 6 min read C# Variables 4 min read C# Literals 5 min read Operators in C# 7 min read C# Keywords 5 min read Control StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch) 5 min read C# Switch Statement 4 min read Loops in C# 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw) 4 min read OOP ConceptsClass and Objects in C# 4 min read Constructors in C# 5 min read C# Inheritance 3 min read Encapsulation in C# 2 min read C# Abstraction 4 min read MethodsMethods in C# 4 min read Method Overloading in C# 4 min read C# | Method Parameters 7 min read Method Overriding in C# 7 min read Anonymous Method in C# 3 min read ArraysArrays in C# 6 min read Jagged Arrays in C# 4 min read Array Class in C# 5 min read How to Sort an Array in C# | Array.Sort() Method Set - 1 8 min read How to find the rank of an array in C# 2 min read ArrayListArrayList in C# 6 min read C# ArrayList Class 7 min read C# | Array vs ArrayList 2 min read StringStrings in C# 6 min read C# Verbatim String Literal - @ 5 min read C# String Class 9 min read C# StringBuilder 4 min read C# String vs StringBuilder 3 min read TupleC# Tuple 7 min read C# Tuple Class 3 min read C# ValueTuple 7 min read C# ValueTuple Struct 4 min read IndexersC# Indexers 4 min read C# Multidimensional Indexers 5 min read C# - Overloading of Indexers 3 min read Like