2014-08-08 11:38:28 -06:00
|
|
|
class X : Y {
|
|
|
|
bool Method (int argument_1, int argument_2)
|
|
|
|
{
|
2014-12-27 23:38:06 -07:00
|
|
|
#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;
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
|
|
|
|
//
|
|
|
|
// This sample helps keep your sanity while using 8-spaces for tabs
|
|
|
|
//
|
2014-12-27 23:38:06 -07:00
|
|
|
VeryLongIdentifierWhichTakesManyArguments (
|
|
|
|
Argument1,
|
|
|
|
Argument2, Argument3,
|
|
|
|
NestedCallHere (
|
|
|
|
MoreNested));
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MyProperty {
|
2014-12-27 23:38:06 -07:00
|
|
|
get { return x; }
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
set { x = value; }
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void AnotherMethod ()
|
|
|
|
{
|
2014-12-27 23:38:06 -07:00
|
|
|
Logger log = new Logger();
|
|
|
|
log.foo.bar = 5;
|
|
|
|
log.narf.sweat = "cat";
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
if ((a + 5) != 4) {
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
while (blah) {
|
|
|
|
if (a)
|
|
|
|
continue;
|
|
|
|
b++;
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object lockA;
|
|
|
|
object lockB;
|
|
|
|
|
|
|
|
void Foo () {
|
2014-12-27 23:38:06 -07:00
|
|
|
lock (lockA) {
|
|
|
|
lock (lockB) {
|
|
|
|
}
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bar () {
|
2014-12-27 23:38:06 -07:00
|
|
|
lock (lockB) {
|
|
|
|
lock (lockA) {
|
|
|
|
}
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// class library
|
|
|
|
class Blah {
|
2014-12-27 23:38:06 -07:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// User
|
|
|
|
class MyBlah {
|
2014-12-27 23:38:06 -07:00
|
|
|
byte[] box = new byte[6];
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
box[2] = 56;
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
void DoStuff ()
|
|
|
|
{
|
|
|
|
lock (this) {
|
|
|
|
int i = GetNumber ();
|
|
|
|
Entry e = GetEntry ();
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
Foo (i, e);
|
|
|
|
}
|
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
|
2014-12-27 23:38:06 -07:00
|
|
|
override void EachBar (Entry e)
|
|
|
|
{
|
2014-08-08 11:38:28 -06:00
|
|
|
lock (this) {
|
2014-12-27 23:38:06 -07:00
|
|
|
DoSomething (e);
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|
2014-12-27 23:38:06 -07:00
|
|
|
}
|
2014-08-08 11:38:28 -06:00
|
|
|
}
|