Difference between parse and tryparse
Parse() method throws an exception if it cannot parse the value, whereas TryParse() method returns a bool indicating whether it succeeded. However, TryParse does not return the value, it returns a status code to indicate whether the parse succeeded and does not throw exception.
Int.Parse(string s) method converts the string to integer. If string s is null, then it will throw ArgumentNullException. If string s is other than integer value, then it will throw FormatException. If string s represents out of integer ranges, then it will throw OverflowException. More.... Convert String to Integer
DateTime.Parse method supports many formats. It is very forgiving in terms of syntax and will parse dates in many different formats. More about.... DateTime.Parse()
In fact the way it is most likely implemented is that internally the Parse() method will call TryParse() method and then throw an exception if it returns false. The advantage of TryParse() method is that it implemented without exceptions so that it is fast.
ParseExact() converts the specified string representation of a date and time to its DateTime equivalent. More.... DateTime.ParseExact()
- Can you store multiple data types in an Array
- What is meant by Hash Code
- Is string a value type or a reference type
- What are the type of Errors
- What is anonymous type ?
- Difference between Singleton and a Static Class
- Difference between Properties and Fields
- What does the [Flags] Enum Attribute Mean?