2022. március 25., péntek

2022.03.25. Distinct - példaprogram

 using System;

using System.Collections.Generic;

using System.Linq;

 

namespace _distinctPelda

{

    class Program

    {

        static void Main(string[] args)

        {

            Random rnd = new Random();

            List<int> l = new List<int>();

            for (int i = 0; i < 10; i++)

            {

                l.Add(rnd.Next(1,10));              

            }

            l.Sort();

            foreach (var item in l)

            {

                Console.WriteLine(item);

            }

            Console.WriteLine();

            List<int> l1 = l.Distinct().ToList();

            foreach (var item in l1)

            {

                Console.WriteLine(item);

            }

 

            Console.ReadLine();

        }

    }

}

Nincsenek megjegyzések:

Megjegyzés küldése