Minimums the specified list. - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

Minimums the specified list.

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;/*  w w w .ja va  2  s.  c  om*/

public class Main{
        /// <summary>
        /// Minimums the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns></returns>
        public static uint Minimum(IEnumerable<uint> list)
        {
            uint min = uint.MaxValue;
            foreach (uint num in list)
            {
                if (min > num)
                {
                    min = num;
                }
            }
            return min;
        }
        /// <summary>
        /// Minimums the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns></returns>
        public static int Minimum(IEnumerable<int> list)
        {
            int min = int.MaxValue;
            foreach (int num in list)
            {
                if (min > num)
                {
                    min = num;
                }
            }
            return min;
        }
}

Related Tutorials