in c#,we often convert data from one type to another.
Sometimes conversions may fail,to manage we will put conversion code block in try catch.
we can get rid off this by using TryParse().
Advantage:
No need to handle exception handling in conversions.
see below example
Sometimes conversions may fail,to manage we will put conversion code block in try catch.
we can get rid off this by using TryParse().
Advantage:
No need to handle exception handling in conversions.
see below example
int quantity=0; if (int.TryParse(txtQuantity.Text, out quantity) == false) { quantity = 0; }
No comments:
Post a Comment