C Sharp Quick Reference

Sorting: List things; things.Sort(delegate(Thing t1, Thing t2)  { return t1.value.CompareTo(t2.value); } ); // CompareTo < 0: this <  other // CompareTo == 0: this == other // CompareTo > 0: this >  other Copying a list of value types (primitives, structs) by value: struct Thing {} List things; List copyOfThings = List(things); Copying a list of reference types (classes) by value: class Thing { int data; public Thing(Thing other) { // copy ctor this.data = other.data; } } // copy list and entries by value List things; copyOfThings = new List(things.Count); foreach(Thing thing in things) copyOfThings.Add(new Thing(thing)); // use copy ctor