C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
The Difference Between 'is' and 'as' Operators
WhatsApp
Garima Taneja
1y
1.6
k
0
2
25
Blog
'is'
'as'
Function
If the run-time type of an expression result is compatible with a given type, the 'is' operator is checked by it.
'as' operator is used to perform conversion between compatible reference types or Nullable types.
Type
Boolean
Non-Boolean
Return type when conversion happens successfully
If the given object is of the same type, then 'is' sends true
'as' sends object when the type of object is compatible with the given type
Return type when conversion not possible
If the given object is not of the same type, then 'is' sends false
'as' returns null if conversion not possible
Use Case
'is' is used for Only Boxing Unboxing and reference conversions
'as' operator is used only for nullable, reference and boxing conversions
Is
As
Keywords
Object
Operators
Boxing
People also reading
Membership not found