cSharp learning course

using System;

public class Program

{

public static void Main(string[] args)

{

using(Dog dog = new Dog())

{

}

}

public class Dog : IDisposable

{

public bool isDisposed;

public Dog()

{

Console.WriteLine("Constructor");

}

public void Dispose()

{

this.Dispose(true);

}

protected void Dispose(bool disposing)

{

if (!this.isDisposed)

{

Console.WriteLine("Deconstructor");

}

this.isDisposed = true;

}

~Dog()

{

this.Dispose(false);

}

}

}

 

2nd method

using System;

public class Program

{

public static void Main (String [] args)

{

Dog A = new Dog();

Console.WriteLine("test");

}

}

class Dog

{

public Dog()

{

Console.WriteLine("Constructor");

}

~Dog()

{

Console.WriteLine("Deconstructor");

}

}



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl