Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Convert string to integer in .net
Convert string to integer in .net

There is a big difference.

Directly adding (int) means forced type conversion. It can only convert similar data types, such as single precision to integer. Regardless of whether it is single precision or integer, it is first of all a numerical type. If what is being converted is a string, it cannot be converted, and an error will be reported during compilation.

But Int32.Parse() is different. It can be said to perform real conversion. It can convert string type data into numeric type data.