Cast, Convert, Parse

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

Guest

Hi,
I'm trying to find out the benefits of one type of conversion method over
another.

When would it be best to use casting over Converting e.g.

(int)stringValue as opposed to

Convert.ToInt(stringValue)

or Parse for that matter:

Int32.Parse(stringValue);


small matters, but interesting to me.

Any ideas would be happily taken on board

Thanks in advance
Ant
 
Hi,

I quick browse thru reflector shows that Convert.ToInt32 internally calls
Int32.Parse.

However, in the IL still they are two different calls. So I guess
Int32.Parse is faster as it has one method call lesser.
 
Back
Top