Događaji
Izgradite inteligentne aplikacije
M03 17 23 - M03 21 23
Pridružite se seriji susreta kako biste sa kolegama programerima i stručnjacima izgradili skalabilna AI rješenja zasnovana na stvarnim slučajevima korištenja.
Registrirajte seOvaj preglednik više nije podržan.
Nadogradite na Microsoft Edge da iskoristite najnovije osobine, sigurnosna ažuriranja i tehničku podršku.
Possibly incorrect assignment to local 'variable' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the original value of the local.
There are several scenarios where using
or lock
blocks will result in a temporary leak of resources. Here is one example:
thisType f = null;
using (f)
{
f = new thisType();
...
}
In this case, the original value, such as null, of the variable thisType
will be disposed of when the using
block finishes executing, but the thisType
object created inside the block will not be, although it will eventually get garbage collected.
To resolve this error, use the following form:
using (thisType f = new thisType())
{
...
}
In this case, the newly allocated thisType
object will be disposed of.
The following code will generate warning CS0728.
// CS0728.cs
using System;
public class ValidBase : IDisposable
{
public void Dispose() { }
}
public class Logger
{
public static void dummy()
{
ValidBase vb = null;
using (vb)
{
vb = null; // CS0728
}
vb = null;
}
public static void Main() { }
}
.NET povratne informacije
.NET je projekat otvorenog koda. Odaberite vezu za pružanje povratnih informacija:
Događaji
Izgradite inteligentne aplikacije
M03 17 23 - M03 21 23
Pridružite se seriji susreta kako biste sa kolegama programerima i stručnjacima izgradili skalabilna AI rješenja zasnovana na stvarnim slučajevima korištenja.
Registrirajte se