Visual Studio .NET - Converting

Asked By Erik Little on 08-Sep-05 12:31 AM
When every converting strings to integers which is the best method?
Int32.Parse
or
cint
Thanks,
Erik...

Parse method is correct

Asked By M Chawla on 08-Sep-05 01:28 AM
Hi!
In c# You can use Int32.Parse() method, which is best method for converting any datatype to integer.
But in c# you cannot use CInt() method,i think.
In vb.net you can use it,but its better to use Int32.Parse() method.
Hope u got it..

Follow Up

Asked By Erik Little on 08-Sep-05 01:33 AM
Thats what i was wondering which one is better to use
Int32.Parse
thanks
erik.

If you are using

Asked By Pinky G on 08-Sep-05 01:51 AM
Hi,
  Int32 is present both in C# as well as in Vb.net but cint is used in only vb.net
cint is compiled inline ie. the conversion code is part of the code that evaluates the expression. Execution is faster. 
Hope this is somewhat informative
Thnks
Follow Up
Asked By Erik Little on 08-Sep-05 01:54 AM
Every thing helps!
Thanks,
Erik...
more
Asked By mv ark on 08-Sep-05 02:26 AM
"Visual Basic .NET includes data type conversion keywords, many of which are carried over from Visual Basic 6. But unlike the Visual Basic 6 functions, these keywords are not function calls but intrinsic language features. The keywords CBool, CByte, CChar, CShort, CInt, CLng, CSng, CDbl, CDec, CDate, CObj, and CStr map to Visual Basic Runtime method calls, .NET Framework class library method calls, or IL type conversion instructions. The exact method call or IL instructions generated depends on the expression against which the conversion is being applied. Some conversions are optimized away, such as CInt(123.45) which is replaced with the integer constant 123 in the IL. This is an example where using the Visual Basic Runtime results in better performance than using the System namespace. CInt("123") becomes a call that leads to calls to System.Double.Parse then System.Math.Round."  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchmicrosoftvisualbasicnetinternals.asp
Use cint
Asked By Sunitha Nambari on 08-Sep-05 04:41 AM
hi,
  CInt is the best way to convert a string into an integer.
Regards,
Suneetha
Follow Up
Asked By Erik Little on 08-Sep-05 10:18 AM
After working with the int32.parse method a little more i can see where the cint is a much better choice for converting strings to integers.
Thanks..