Parse()

noun

say it: “PARS” /pɑːrs/

A method such as int.Parse that turns text into a number and stops with an error if the text is not a number.

What is Parse() in C#?

Parse() — A method on a number type, such as int.Parse or decimal.Parse, that turns text into that number. If the text isn't a number, it throws a FormatException, so use it only when you're sure of the text.

int pages = int.Parse("320");
Console.WriteLine(pages + 1); // 321

int oops = int.Parse("three"); // FormatException

In a sentence

  • “I used int.Parse on the page count from the file, because it is always a number.”

Level: Apprentice · More C# terms at this level

Updated