converting string to integer and vice versa | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

converting string to integer and vice versa

Just wondering why is this code even used? Because lets say for example: string text = "5"; int number = Convert.ToInt32(text); instead of doing this whole converting method cant we just remove the apostrophes from the number to make it an integer inside of adding the Convert.ToInt32 line?

26th Mar 2023, 11:26 AM
kevin thapa
kevin thapa - avatar
1 Answer
+ 2
Why you want to do long process when you have default method Convert.ToInt32 which gives you a number. If you just remove by another method then still it will be a string not a number.
26th Mar 2023, 11:56 AM
A͢J
A͢J - avatar