Skip to content

Instantly share code, notes, and snippets.

@ledpup
ledpup / Virtual
Created July 6, 2012 05:46
Demonstrates the use of virtual, override, sealed and new keywords on methods.
public class Base
{
public virtual void Method()
{
Console.WriteLine("Base (can be overridden.)");
}
public void CantOverride()
{
Console.WriteLine("Can't be overridden (but can be newed).");
@ledpup
ledpup / RangeOverlap
Created July 5, 2012 23:42
Check for overlap between ranges of values. E.g., date ranges, numeric ranges.
class Range<T>
{
public readonly T Start;
public readonly T End;
public Range(T start, T end)
{
Start = start;
End = end;
}