ghj Grandhe
asked on
Input string was not in a correct format
Getting Input String Was not in a correct Format
.Actually I had written a method in webservice as method name as caculator
[WebMethod]
public int caculator(int firstNumber,int secondNumber,string operation)
{
int result = 0;
switch(operation)
{
case "+": result = firstNumber + secondNumber;
break;
case "-": result = firstNumber - secondNumber;
break;
case "*": result = firstNumber * secondNumber;
break;
case "/":result = firstNumber / secondNumber;
break;
}
return result;
}
and Iam consuming this in webapplication where I have written as
private void BindData()
{
string operation = txtOperation.Text;
WebService1 objWebService = new WebService1();
int result=objWebService.cacul ator(int.P arse(txtFi rstNumber. Text), int.Parse(txtSecondNumber. Text), operation);
if (result != 0)
Response.Write(result);
}
in this iam getting error at this line
int result=objWebService.cacul ator(int.P arse(txtFi rstNumber. Text), int.Parse(txtSecondNumber. Text), operation);
i doesn't understand why iam getting error here. Even though i converted it into string
could you please suggest as soon as possible
.Actually I had written a method in webservice as method name as caculator
[WebMethod]
public int caculator(int firstNumber,int secondNumber,string operation)
{
int result = 0;
switch(operation)
{
case "+": result = firstNumber + secondNumber;
break;
case "-": result = firstNumber - secondNumber;
break;
case "*": result = firstNumber * secondNumber;
break;
case "/":result = firstNumber / secondNumber;
break;
}
return result;
}
and Iam consuming this in webapplication where I have written as
private void BindData()
{
string operation = txtOperation.Text;
WebService1 objWebService = new WebService1();
int result=objWebService.cacul
if (result != 0)
Response.Write(result);
}
in this iam getting error at this line
int result=objWebService.cacul
i doesn't understand why iam getting error here. Even though i converted it into string
could you please suggest as soon as possible
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So did you find the issue?
ASKER
yes, i found out that the issue is causing in int.parse and i rechanged to int.tryparse.
That is great. Please close this question by selecting those solutions that helped.
Thanks
Fernando
Thanks
Fernando
I'd suggest you split over the first three comments.
ASKER
Thanks
ASKER