0
You could do it like this (if the textbox is empty, the variable will be assigned a value of 0):
sm = new fee_endow();
int a, b, c, d, e;
int.TryParse(sum1.Text, out a);
int.TryParse(sum2.Text, out b);
int.TryParse(sum3.Text, out c);
int.TryParse(sum4.Text, out d);
int.TryParse(sum5.Text, out e);
sm1 = sm.add(a, b, c, d, e);
totalbox.Text = sm1.ToString();
Accepted 0
Sure, the int.TryParse returns a bool indicating whether the first parameter can be parsed to an int or not.
If it can, then the 'out' parameter contains the value of that int.
If it can't, then the 'out' parameter contains 0.
So, if the first parameter is an empty string or something like 'abc', then it can't be parsed to an int and the out parameter will contain zero, which is what you wanted.
Here, we're not interested in the bool return value and so just ignore it.
'out' parameters are a form of 'passing by reference. However, unlike 'ref', the variable does not need to be initialized first but the compiler guarantees that it will have a value by the time the method returns.
0
Thnx it's working. one more favor can u xplain how does out a, out b work??
0
Convert.ToInt32(TextBoxToTalTickets.Text)+Convert.ToInt32(TextBox2.Text)+
Convert.ToInt32(TextBox2.Text)..................
u can use this man