I have two methods
public void GetEmp()
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new System.Uri("http://sdw2629/empservice/EmployeeInfo.svc/Employee"));
request.Method = "GET";
request.ContentType = "application/json; charset=utf-8";
request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
}
and
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult))
{
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string results = httpwebStreamReader.ReadToEnd();
//execute UI stuff on UI thread.
}
}
}
Here i want to return a string "results" to some other method like this
string data= obj1.GetEmp()
How can i achieve this.. Any help would be appriciated.. Thanks