int.Parse() / ToString()
Text ↔ number conversion.
Syntax
int.Parse(text) // number.ToString()
Description
int.Parse converts text to an integer, and double.Parse converts it to a decimal. ToString converts a number to text. Unconvertible text throws an error.
Example
Loading editor…
Expected output
30 42!
When to use?
Accounting for text coming from users/files.
Common mistakes
- ⚠️ int.Parse("abc") throws an error; TryParse is safer.