C# conversion between numeric and string

  • Blogger writing is not easy, kids need your encouragement
  • Thousands of waters and thousands of mountains are always in love, so please click a like first.

method

ToString() method: ToString() method of numeric type can convert numeric data into a string;
Parse() method: Parse() method of numeric type can convert a string to numeric.

example

ToString() method

int num = 25;
string str = num .ToString();
double dnum = 25.01;
string str = dnum .ToString();

Parse() method

string str = "25";
int num = int.Parse( str );
string str = "25.56";
double dnum = double.Parse( str );
  • About the blogger:
  • Industrial automation upper computer software engineer, machine vision algorithm engineer, motion control algorithm engineer. Currently working in the intelligent manufacturing automation industry. Blogger's mailbox: [email protected]
  • Help me like it. Haha.

Guess you like

Origin blog.csdn.net/cashmood/article/details/109093469