Keyword As and Is in C # [duplicate]

-1

Well ... I was a bit confused as the keywords As and Is in C # ... I did not understand the difference between them nor what they are for ... I believe it is not so difficult to find a splint on the internet, but I prefer to ask here, because the websites did not go deep into this subject ...

    
asked by anonymous 27.10.2018 / 08:25

1 answer

1

"is" and "as" are key words used to convert data types. "is": Checks whether an object is compatible with a data type and returns true or false. Ex: if (obj is Product) {}. "as" tries to convert an object to a specific type. If the conversion fails it returns null.

To help you better understand the difference in this link you have a good explanation with sample codes. link

    
27.10.2018 / 10:52