Dispose
twice is UB CS-W1014The Dispose
method is used to dispose-off any resources that were acquired or used by an object. The using
keyword automatically calls the Dispose
method as soon as it goes out of scope, thereby eliminating the need for calling it manually. Since it may cause UB, it is recommended that you remove such explicit calls.
using (var c = new Class())
{
// ...
c.Dispose();
}
using (var c = new Class())
{
// ...
}