Advantage between (int) and Convert.ToInt32?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any advantage, or a recommended preference, between using (int) or
Convert.ToInt32() to convert numeric types to System.Integer32 ?

Thanks,
 
Hi,

They are two different concepts, the first is a cast , for this to work the
casted type should be convertible to int , no all of the types are.

The second are a series of method with different signatures, each overloaded
version perform the needed conversion.

IMO a cast should be faster than calling Convert.XXX but I cannot garantee
it, it does depend of the typed being converted.

cheers,
 

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