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