C#;functional programming;design-by-contract

Fun with contracts and anonymous delegates

I officially blew my own mind today. I discovered System.Diagnostics.Contracts and inline declaration and invocation of anonymous delegates all in the same day...

namespace FunWithContracts
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;

    internal static class Program
    {
        private static void MySort<T>(T[] array, int index, int length, IComparer<T> comparer)
        {
            Contract.Requires<ArgumentNullException>(array != null);
Syndicate content