Articles → CSHARP → Sortedset In C#

Sortedset In C#






Purpose





Example


using System;
using System.Collections.Generic;


namespace SortedsetDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedSet<int> sortedSet = new SortedSet<int>();
            sortedSet.Add(3);
            sortedSet.Add(2);
            sortedSet.Add(5);
            sortedSet.Add(1);

            foreach (int element in sortedSet)
            {
                Console.WriteLine(element.ToString() + Environment.NewLine);
            }
            Console.ReadLine();
        }
    }
}




Output




Picture showing the output of the sortedset in C#



Posted By  -  Karan Gupta
 
Posted On  -  Friday, January 22, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250