title: C# WinForms Try Catch Inside a class
body: <p>I am using a service reference which connects to internet and I want to show message in a message box if ever the connection fails. How will I call message box in the member function of the class which has void return type? This is the member function of the class:</p>
  
  <pre><code> public void ReverseGeocodePoint()
      {
          try{
          string results = "";
          string key = "abc";
          ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
  
          // Set the credentials using a valid Bing Maps key
          reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
          reverseGeocodeRequest.Credentials.ApplicationId = key;
  
          // Set the point to use to find a matching address
          GeocodeService.Location point = new GeocodeService.Location();
          point.Latitude = latitude;
          point.Longitude = longitude;
  
          reverseGeocodeRequest.Location = point;
  
          // Make the reverse geocode request
          GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
          //This will connect to the server
          GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);
  
          if (geocodeResponse.Results.Length &gt; 0)
              results = geocodeResponse.Results[0].DisplayName;
          else
              results = "No Results found";
  
          address = results;
      }} catch{ //here I want to show a msgbox but the problem is, this is not the form class}
  </code></pre>