+ 2

Casting

what about casting in c# why used it ?

26th Feb 2018, 7:50 AM
Zeyad Sharo
Zeyad Sharo - avatar
4 Answers
+ 5
It is a way of changind data types of variables. "123" is a string 123 is an integer
26th Feb 2018, 8:06 AM
Gami
Gami - avatar
+ 3
in case you have to cast a short to an integer for example
26th Feb 2018, 7:57 AM
Tim Millar
Tim Millar - avatar
26th Feb 2018, 8:43 AM
Zeyad Sharo
Zeyad Sharo - avatar
+ 1
yes, like int a = 567; long b = a; it's upcast ..secure casting with no data loses. Downcast is insecure..
26th Feb 2018, 8:09 AM
Serhii Ivaniuk
Serhii Ivaniuk - avatar