Simple service for example..
IService
[ServiceContract]
public interface IService
{
[OperationContract]
string Calculate(int price, int Qty);
}
Service
public class Service : IService
{
public string Calculate(int price, int Qty)
{
return Convert.ToString(price * Qty);
}
}
Consume service by user
Go to Add Service reference option and discover the service. Add the service. Now the service displays in solution explorer.
http://localhost/WCFServiceSample/Service.svc
To check in web browser.
Usage in Application
using WindowsFormsApplicationWCF.ServiceReference1;
Service1Client obj = new Service1Client();
private void btnSubmit_Click(object sender, EventArgs e)
{
string result;
result = obj.Calculate(Convert.ToInt32(txtPrice.Text), Convert.ToInt32(txtQty.Text));
lblresult.Text = "The total price is" + result;
}
Check these links for you reference,
Hosting WCF service inside a Windows Forms application
http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-wcf-service-in-windows-application/
https://msdn.microsoft.com/en-us/library/ms731758(v=vs.110).aspx