using System;

public class Person1
{
	//other methods not shown
	~Person1()
	{
		//call your clean-up code
		CleanUp();
	}

	void CleanUp()
	{
		//code to free scarce resources
	}
}

public class Person : IDisposable
{
	//other methods not shown
	~Person()
	{
		//call your clean-up code
		CleanUp();
	}
	void CleanUp()
	{
		//code to free scarce resources
	}

	public void Dispose()
	{
		GC.SuppressFinalize(this);
		CleanUp();
	}
}

class App
{
	static void Main()
	{
		Person per = new Person();
		try
		{
			//do something with per
		}
		finally
		{
			per.Dispose();
		}

		// 2. Using in C#
		using (Person per2 = new Person())
		{
			//do something with per2
		}	//Dispose is called here with using
	}
}

