Created
October 19, 2013 10:40
-
-
Save Fhernd/7054329 to your computer and use it in GitHub Desktop.
Demostración de un destructor en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
public class Contador | |
{ | |
private Stopwatch cronometro; | |
public Contador () | |
{ | |
cronometro = Stopwatch.StartNew (); | |
Console.WriteLine ("Se ha instanciado un objeto."); | |
} | |
public void MostrarDuracion () | |
{ | |
Console.WriteLine ("La instancia {0} ha tenido una duración de: {1}.", this, cronometro.Elapsed); | |
} | |
~Contador () | |
{ | |
Console.WriteLine ("Se iniciado la finalización del objeto."); | |
cronometro.Stop (); | |
Console.WriteLine ("La instancia {0} ha tenido una duración de: {1}.", this, cronometro.Elapsed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment