I have an assingment and I'm a bit lost. In an array of 10 (or less) numbers which the user enters (I have this part done), I need to find the second smallest number. My friend sent me this code, but I'm having a hard time understanding it and writing it in c#:
Solved it!!! :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int vnesena;
            int? min1 = null;
            int? min2 = null;
            for(int i=1; i<11; i=i+1)
            {
                Console.WriteLine("Vpiši " + i +"." + " število: ");
                vnesena = Convert.ToInt32(Console.ReadLine());
                if (vnesena == 0)
                {
                    break;
                }
                if (min1 == null || vnesena < min1)
                {
                    min2 = min1;
                    min1 = vnesena;
                }
                else if (vnesena != min1 && (min2==null || vnesena<min2))
                {
                    min2 = vnesena;
                }
            }
            if (min1 == null || min2 == null)
            {
                Console.WriteLine("Opozorilo o napaki");
            }
            else
            {
                Console.WriteLine("Izhod: " + min2);
            }
            Console.ReadKey();
        }
    }
}
 
     
     
    