Interviews3 answers
Why should not use AS operator for the typecating in Value type? float c = 20; e.g. int a = c as int; its wrong. Why?
Posted Dec 2, 2014, 6:50 AM EST.NET
3 Answers
As operator is used mainly with References type or null able type because if conversion is not possible then it return NULL value but int can not store it so we can not us "AS" operator with non-nullable value type
Pankaj Kumar ChoudharyPosted May 27, 2015, 8:55 AM EDT
Note that 'as' operator relies on implicit typecasting. Using as implies that you actually know the type of the variable at the compile time (or can assert that it will be what you expect). Rest is correctly mentioned by Gul Md Ershad.
Vaibhav SinghPosted Mar 11, 2015, 8:05 AM EDT
