9

Hi I am using RestClient from RestSharp nuget package, but I found it does not implement IDisposable. So do I need to dispose it or how to dispose it?

The example codes are from Mailgun api:

RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.AddParameter ("domain", "YOUR_DOMAIN_NAME", ParameterType.UrlSegment);
        request.Resource = "{domain}/messages.mime";
        request.AddParameter ("to", "bar@example.com");
        request.AddFile ("message", Path.Combine ("files", "message.mime"));
        request.Method = Method.POST;
        return client.Execute (request);
DennisL
  • 293
  • 1
  • 3
  • 12
  • 1
    [duplicate](https://stackoverflow.com/questions/26907879/dispose-object-of-restrequest-restsharp)? – rt2800 Dec 22 '17 at 11:48
  • 3
    There is nothing to explicitly dispose. Garbage collector will take care of freeing resources. – Alexey Zimarev Dec 22 '17 at 20:45
  • Does this answer your question? [Dispose Object Of RestRequest RestSharp?](https://stackoverflow.com/questions/26907879/dispose-object-of-restrequest-restsharp) – Eldar Jun 27 '21 at 13:22

0 Answers0