In the process of programming, data conversion is often used, there are many methods of data conversion in C #, there are four ways to convert the target object to int (int.): (int), int, respectively. Parse (), Int. TryParse () and Convert.ToInt32 (
Statmoon Source: http://leolis.cnblogs.com/In the process of programming, data conversion is often used, there are many methods of data conversion in C #, there are four ways to convert the target object to int (int.): (int), int, respectively.
Data conversion is often used in programming. There are many data conversion methods in C #. There are four methods to convert the target object to an integer (INT: they are (INT) and Int. parse (), Int. tryparse () and convert. toint32 (), What are
Transferred from: http://www.cnblogs.com/leolis/p/3968943.htmlIn the process of programming, data conversion is often used, there are many methods of data conversion in C #, there are four ways to convert the target object to int (int.): (int), int,
Writen by Allen Lee
Q: How to resolve a string to an int?
A: There are three simple methods:
String source = "1412 ";
Int result = 0;
// Use convert. toint32 (string value );
Result = convert. toint32 (source );
// Use int32.parse (string value );
In C #, what are the differences between (INT), int32.parse (), convert. toint32 (), and int32.tryparse?
The Int keyword indicates an integer that is 32-bit. Its. NET Framework type is system. int32.If int32.tryparse () does not throw an exception,
In C #, what are the differences between (int), Int32.Parse () and Convert. toInt32?
The int keyword indicates an integer that is 32-bit. Its. NET Framework type is System. Int32.
(Int) indicates explicit forced conversion, which is a type
In previous projects, I seldom paid attention to convert, parse, tryparse, Int, and other differences. I found that these details were very important only recently, and I felt that convert, parse, tryparse, and INT were the best way to use them;
I have just learned C # programming language, summed up a little bit of knowledge, want to share to everyone. After all, just learning this language, not learning deeply, where if there are errors, please help to point out ha, thank you! 1, (int)
1, int is suitable for conversion between simple data types, the default integral type of C # is int32 (bool type is not supported);2, Int. Parse (String sparameter) is a constructor, and parameter types only support string types;3. Convert.ToInt32 (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.