- 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
- Static keyword in C#
- C# | finally keyword
- Invoking an overloaded constructor using this keyword in C#
- Difference between readonly and const keyword in C#
- C# | Operator Overloading
- Garbage Collection in C# | .NET Framework
- Local Function in C#
- C# | Graphics.DrawLine() Method | Set - 1
- C# | Uri.Equals(Object) Method
- C# | Uri.CheckSchemeName(String) Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.