Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
The Difference Between 'is' and 'as' Operators
WhatsApp
Garima Taneja
May 29
1.5
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
As
Boxing
Is
Keywords
Object
Operators
Up Next
Remove AM PM from Time String using C#
Ebook Download
View all
Introduction to C# 8
Read by 19.3k people
Download Now!
Learn
View all
Membership not found