I am sharing the difference between IS and As operator with example that is below.
IS - It returns the result as a Boolean (True Or False) . It is used to Check the Compatibility of an Object with a given Type.
Example:-
AS - This is used to Casting of Object to a given Type.
Example:-
IS - It returns the result as a Boolean (True Or False) . It is used to Check the Compatibility of an Object with a given Type.
Example:-
if (your_Object is StringBuilder) { } else{ }
AS - This is used to Casting of Object to a given Type.
Example:-
StringBuilder obj = your_Object as StringBuilder; if (obj != null) { } else { }
No comments:
Post a comment