In C #, there is more than a conversion between data of numeric types, and strings and numbers can be converted to each other, but only in different ways.
1 numeric conversions to char type
It is possible to convert numeric data to strings with the ToString () method.
int num1=10
String Mynum=num1. ToString ();
2 string converted to numeric type
Convert string data to numeric using the Pares () method
The string is converted to integer with int. Pares ()
String str= "13";
int Number=int. Pares (str);
The string is converted to a double-precision floating-point double. Pares () string
String str= "14";
Double number =double. Pares (str);
The string is converted to a single-precision float float. Parse (String)
String str= "15";
Float number=float. Pares (str);
Not knowing that a string can be converted to numeric data, only a string capable of being represented as a number can be converted, such as the name "Zhang San", and the conversion to a number that does not conform to an expression is not possible.
Note the arguments in Pares () brackets can only be strings and cannot be other data types.
Conversion between C # strings and data