I've got a need to store a disposable object as a class member. This is HttpClient which is disposable and I can either dispose it manually or put it into using(var client=new ....). Now imagine such situation:
public class Session
{
private HttpClient m_httpClient;
public Session()
{
m_httpClient = new HttpClient();
}
}
How do I dispose HttpClient
? Does the garbage collector when deleting session takes care of disposable HttpClient
also ? There are destructors in C++. In C# it's not neccessary. Should I make session object disposable too then? Thank you.