Exemplo n.º 1
0
        public delegate void NumberCount(int count); // Create delegate

        public static void CallAnonymousToCheckImplicitConversion()
        {
            NumberCount count = delegate(int counts)
            {
                Console.WriteLine(counts);
            };

            count(45);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Helper to decrement a NumberCount or remove it when it reaches 0
    /// </summary>
    private static void RemoveFromSetAsPriorityQueue(SortedSet <NumberCount> setAsPriorityQueue, int number)
    {
        Solution.placeHolderNumberCount.number = number;
        SortedSet <NumberCount> existing = setAsPriorityQueue.GetViewBetween(Solution.placeHolderNumberCount, Solution.placeHolderNumberCount);

        // assert existing.Count == 1
        NumberCount numberCount = existing.Max;

        if (numberCount.count == 1)
        {
            setAsPriorityQueue.Remove(numberCount);
        }
        else
        {
            numberCount.count--;
        }
    }