1, int convert string
Method: ToString () or convert.tostring ()
Example:
[Code]phpcode://tostring () int a = 1; String B = a.tostring (); Convert.ToString () int a = 1; String B = convert.tostring (a);
2. String conversion int
(1) If you are sure that a character in a string can be converted to a number, you can use Int. Parse (string s), which returns the converted int value;
(2) If you cannot determine whether a string can be converted to a number, you can use Int. TryParse (string s, out int result), which returns a bool value indicating whether the conversion operation was successful, and the parameter result is a variable that holds the result of the conversion.
[code]phpcode://(1) string str = string. Empty; str = "123"; int Result=int. Parse (str); (2) string str = string. Empty; str = "XYZ"; int result; Int. TryParse (str, out result);
"C # base" int conversion string,string convert int