What is the difference between the two types of casts available in c#?
Specifically, what is the difference between.
(int)7.6 and 7.6 as int and similar casts?
What is the difference between the two types of casts available in c#?
Specifically, what is the difference between.
(int)7.6 and 7.6 as int and similar casts?
as will return null if it can't convert to the given type. Casting will throw an exception
The as operator is like a cast operation. However, if the conversion isn't possible, as returns null.
if you use an implicit cast and the cast is not possible you will get an exception.