private static int disposeCount = 0;
public ref struct Scope(object myObject) {
private object? myObject = myObject;
public void Dispose() {
object? obj = myObject;
if (obj != null) {
myObject = null;
disposeCount++;
}
}
}
public static void Main() {
using (Scope scope1 = new Scope("some object")) {
Scope scope2 = scope1;
scope2.Dispose();
}
Console.WriteLine(disposeCount);
}
private static int disposeCount = 0;
public ref struct Scope(object myObject) {
private object? myObject = myObject;
public void Dispose() {
object? obj = myObject;
if (obj != null) {
myObject = null;
disposeCount++;
}
}
}
public static void Main() {
using (Scope scope1 = new Scope("some object")) {
Scope scope2 = scope1;
scope2.Dispose();
}
Console.WriteLine(disposeCount);
}