Disposable not disposed (ARCH1101)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key dotnet.resource.disposable-not-disposed · Severity warning · Category resource
If an object implementing IDisposable is not disposed, unmanaged resources leak. Wrap local disposable objects with using.
Incorrect
Section titled “Incorrect”var connection = new SqlConnection(connectionString);connection.Open();var command = connection.CreateCommand();Correct
Section titled “Correct”using var connection = new SqlConnection(connectionString);connection.Open();var command = connection.CreateCommand();Wrap the disposable object in a using declaration or using block so it is disposed automatically when it goes out of scope.