Type Conversion Question

  • Thread starter Thread starter Paul Hetherington
  • Start date Start date
P

Paul Hetherington

Hi,
Which is the more recomended way to do type conversion in C# for basic data
types(integer, singles, doubles etc...)
System.Convert.ToSingle,ToInt32 etc...?
or (float)myvar; (int)myvar, etc..?

TIA
 
In the first case, the runtime does the conversion for you. In the second
case, the compiler does the conversion. Where possible, if left to me, I'll
let the compiler do these kind of basic type conversions - because it's done
once during compile phase and makes my code snappier.

-vJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top