+ 1

difference "C casting" VS Convert.<Type>

Any significative difference between: float f = (float)double_var; & float f = Convert.ToSingle(double_var);

5th Mar 2021, 4:25 PM
Kiwwi#
Kiwwi# - avatar
2 Answers
+ 2
Adriano Repetti: "Even if you may see them somehow as equivalent they're completely different in purpose. Let's first try to define what a cast is: Casting is the action of changing an entity of one data type into another. It's a little bit generic and it's somehow equivalent to a conversion because a cast often has the same syntax of a conversion so the question should be when a cast (implicit or explicit) is allowed by the language and when do you have to use a (more) explicit conversion?" Refrence https://stackoverflow.com/questions/15394032/difference-between-casting-and-using-the-convert-to-method
5th Mar 2021, 8:55 PM
hossein B
hossein B - avatar
+ 1
hossein B thx 4 answer, I was looking for some "technical" explanation of what happens at code level
5th Mar 2021, 9:51 PM
Kiwwi#
Kiwwi# - avatar