try-parse

Using TryParse for Setting Object Property Values

I'm currently refactoring code to replace Convert.To's to TryParse. I've come across the following bit of code which is creating and assigning a property to an object. List<Person> list = new List<Person>(); foreach (DataRow row in dt.Rows) { var p = new Person{ RecordID = Convert.ToInt32(row["ContactID"]) }; list.Add(p); }...

Parse v. TryParse

What is the difference between parse and TryParse? int number = int.Parse(textBoxNumber.Text); // The Try-Parse Method int.TryParse(textBoxNumber.Text, out number); Is there some form of error-checking like a Try-Catch Block? ...