1 // Namespace Declaration 2 Using System; 3 4 // Helper class 5 Class Outputclass 6 { 7 String Mystring; 8 9 // Constructor 10 Public Outputclass ( String Inputstring) 11 { 12 Mystring = Inputstring; 13 } 14 15 // This points to a specific object, which produces calls to its own constructor with parameters. 16 Public Outputclass (): This ( " Default string " ) 17 { 18 } 19 20 // Instance method 21 Public Void Printstring () 22 { 23 Console. writeline ( " {0} " , Mystring ); 24 } 25 26 // Destructor 27 ~ Outputclass () 28 { 29 // Some resource cleanup routines 30 } 31 } 32 33 // Program start class 34 Class Exampleclass 35 { 36 // Main begins program execution. 37 Public Static Void Main () 38 { 39 // Instance of outputclass 40 Outputclass outcl = New Outputclass (); 41 42 Outputclass outc2 = New Outputclass ( " This is printed by the output class. " ); 43 44 // Call output class 'method 45 Outcl. printstring (); 46 47 Outc2.printstring (); 48 } 49 }