On Github wwwind / wwwind.github.io
Created by Elena Zhelezina
decimal d = 10.1M; double dip = double.InfinityPositive; double din = double.InfinityNegative; double nan = double.NaN; string str = double.ToString();
return (!windy && (rainy || sunny)); return (!windy & (rainy | sunny));
int x = 9; object obj = x; // box the int int y = (int)obj; // unbox the int // copied int i = 3; object boxed = i; i = 5; Console.WriteLine(boxed); //3
public class Asset { public string Name; public virtual decimal Liability { get {return 0;}} public sealed void getData {...} } // can inherit just one class public class House: Asset { public decimal Morgage; public override decimal Liability { get {return Morgage;}} }
// PaymentFormGen.cs - auto-generated partial class PaymentForm {..} // PaymentForm.cs - hand-generated partial class PaymentForm {..}
public interface IEnumerator { bool MoveNext(); object Current {get;} void Reset(); }
internal class Countdown: IEnumerator { int count = 11; public bool MoveNext() {return count-- > 0;} public object Current { get {return count;}} public void Reset() { throw new NotSupportedException();} }
class GenericClass<T, U> where T: SomeClass, SomeInterface where U : new() {...}
Stack<Bear> bears = new Stack<Bear>(); Stack<Animal> animals = bears; // Compile-time error
public interface IPushable<in T> { void Push (T obj); } IPushable<Animal> animals = new Stack<Animal>(); IPushable<Bear> bears = animals; bears.Push(new Bear());