C#

C#

Made by DeepSource

Calling Dispose twice is UB CS-W1014

Bug risk
Major

The 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.

Bad Practice

using (var c = new Class())
{
    // ...
    c.Dispose();
}

Recommended

using (var c = new Class())
{
    // ...
}

Reference