|
using System;
using System.IO;
namespace Finalizers
{
internal class FileGenerator : IDisposable
{
public FileGenerator()
{
}
~FileGenerator()
{
// Just a debug output
Console.WriteLine("Closing file!");
}
public void Generate(int Length)
{
// Here some work is done...
}
public void Dispose()
{
// Just a debug output
Console.WriteLine("Disposing object!");
}
}
class Program
{
static void Generate()
{
// Here it would be better to use the C# "using" keyword instead of implicitly calling Dispose!
using ( var fGen = new FileGenerator() )
fGen.Generate(512);
//fGen.Dispose();
}
static void Main(string[] args)
{
Generate();
// Here we do some work; simulated by ReadLine statement
Console.Write("Please Press Enter...");
Console.ReadLine();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hi, my name is Rainer Stropek. I am living a small city named Traun in Austria. Since 1993 I have worked as a developer and IT consultant focusing on building database oriented solutions. After being a freelancer for more than six years I founded a small IT consulting company together with some partners in 1999. In 2007 my friend Karin and I decided that we wanted to build a business based on COTS (component off-the-shelf) software. As a result we founded "software architects" and developed the time tracking software "time cockpit" (
http://www.timecockpit.com). If you want to know more about our companies check out my blogs at
http://www.software-architects.com and
http://www.timecockpit.com or take a look at my profile in XING (
http://www.openbc.com/hp/Rainer_Stropek2/).
I graduated the Higher Technical School for MIS at Leonding (A) in 1993. After that I started to study MIS at the Johannes Kepler University Linz (A). Unfortunately I had to stop my study because at that time it was incompatible with my work. In 2005 I finally finished my BSc (Hons) in Computing at the University of Derby (UK). Currently I focus on IT consulting, development, training and giving speeches in the area of .NET and WPF, SQL Server and Data Warehousing.