I'm writing an example as you requested above.
1. Before adding two numbers we have to create method for adding two numbers in webservice.
Write the following code in Service1.asmx.cs (My webservice name is WebService1).
[WebMethod]
Public int Sum(int a,int b)
{
int a,b;
int sum=a+b;
return sum;
}
the above method returning sum, so we get the sum value in Form1.
After that run the WebService1 and copy the service URL from browser. Create the form application then follow the below steps.
1.Solution Explorer>Right Click> Add Service Refrence> Paste the service url> click Ok.
2.Then write the below code in the button click event.
private void ButtonLogin_Click(object sender, EventArgs e)
{
int a,b;
a=Convert.ToInt(textBox1.Text);
b=Convert.ToInt(textBox2.Text);
myService.Service1SoapClient client = new Service1SoapClient();
client.ValidateQueryCompleted += new EventHandler<validatequerycompletedeventargs>(client_ValidateQueryCompleted);
client.ValidateQueryAsync(a,b);
}
void client_ValidateQueryCompleted(object sender, ValidateQueryCompletedEventArgs e)
{
MessageBox.Show(sum.ToString());
}
</validatequerycompletedeventargs>