static void Main(string[] args) { // vienkarshi Messiah jesus = new Messiah(); System.Console.WriteLine( "You are " + jesus.save() ); jesus.Dispose();
// efektiivi, bet ne korekti System.Console.WriteLine( "You are " + ( new Messiah() ).save() );
// konkreeti System.Console.WriteLine( "You are " + Jesus.saves() ); }
[...]
class Messiah: IDisposable { public string save() { return "saved"; }
#region IDisposable Members
public void Dispose() { // TODO: Add Messiah.Dispose implementation }
#endregion }
class Jesus: Messiah { public static string saves() { using( Messiah j = new Messiah() ) { return j.save(); } } }
|