- 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:
True True True True True False False
Example of as operator:
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
- C# | as Operator Keyword
- C# | is Operator Keyword
- typeof Operator Keyword in C#
- C# | this Keyword
- LINQ | Let Keyword
- Static keyword in C#
- C# | finally keyword
- How to implement is functionality without using is keyword in C#
- Difference between readonly and const keyword in C#
- Invoking an overloaded constructor using this keyword in C#
- LINQ | Set Operator | Except
- C# | Operator Overloading
- LINQ | Set Operator | Union
- LINQ | Quantifier Operator | All
- LINQ | Quantifier Operator | Any
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.