C-sharp beginners' questions about Index out of range

I am a beginner in C-sharp, and I recently encountered a problem. I don"t understand why I got this error
index was out of range.Must be non-negative and less than size of the collection
code as follows
class Program

{
    delegate bool Function(int a , int b);
    static Function b = delegate(int a ,int b){return a>=b;};
    static Function a = delegate(int a ,int b){return a<=b;};
    static List<int> Lis(List<int> nums , Function function)
    {
        var list = new List<int>();                        
        int maxOrMin  = list[0];
        foreach(int num in nums)
        {
            if(function(num,maxOrMin))
            {
                maxOrMin = num;
            }
        }
        list.Add(maxOrMin);
        return list;    
    }
    static void Main()
    {
        var list = Lis(new List<int> (){1,2,3,4,5,6} , b);
        foreach(var lis in list)
        {
            Console.WriteLine(lis);
        }
    }
}
Mar.04,2021

should be the problem here

var list = new List<int>();                        
int maxOrMin  = list[0];

the newly created List has a size of 0, while list [0] refers to the first element, which obviously does not exist

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eae6c5-47fac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eae6c5-47fac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?