1 class X : Y { Method(int argument_1, int argument_2)2 bool Method (int argument_1, int argument_2) 3 { 4 #region something 5 int foo = 0; 6 #endregion 7 8 if (argument_1 == argument_2) 9 throw new Exception (Locale.GetText ("They are equal!")); 10 11 if (argument_1 < argument_2) { 12 if (argument_1 * 3 > 4) 13 return true; 14 else 15 return false; 16 } 17 18 // 19 // This sample helps keep your sanity while using 8-spaces for tabs 20 // 21 VeryLongIdentifierWhichTakesManyArguments ( 22 Argument1, 23 Argument2, Argument3, 24 NestedCallHere ( 25 MoreNested)); 26 } 27 28 bool MyProperty { 29 get { return x; } 30 31 set { x = value; } 32 } 33 AnotherMethod()34 void AnotherMethod () 35 { 36 Logger log = new Logger (); 37 38 log.foo.bar = 5; 39 log.narf.sweat = "cat"; 40 41 if ((a + 5) != 4) { 42 } 43 44 while (blah) { 45 if (a) 46 continue; 47 b++; 48 } 49 } 50 } 51 52 object lockA; 53 object lockB; 54 Foo()55void Foo () 56 { 57 lock (lockA) { 58 lock (lockB) { 59 } 60 } 61 } 62 Bar()63void Bar () 64 { 65 lock (lockB) { 66 lock (lockA) { 67 } 68 } 69 } 70 71 72 // class library 73 class Blah { 74 Hashtable ht; Foo(int zzz, Entry blah)75 void Foo (int zzz, Entry blah) 76 { 77 lock (ht) { 78 ht.Add (zzz, blah); 79 } 80 } 81 Bar()82 void Bar () 83 { 84 lock (ht) { 85 foreach (Entry e in ht) 86 EachBar (e); 87 } 88 } 89 EachBar(Entry e)90 virtual void EachBar (Entry e) 91 { 92 } 93 } 94 95 // User 96 class MyBlah { 97 byte[] box = new byte [6]; 98 99 box [2] = 56; 100 DoStuff()101 void DoStuff () 102 { 103 lock (this) { 104 int i = GetNumber (); 105 Entry e = GetEntry (); 106 107 Foo (i, e); 108 } 109 } 110 EachBar(Entry e)111 override void EachBar (Entry e) 112 { 113 lock (this) { 114 DoSomething (e); 115 } 116 } 117 } 118 119