Javatpoint Logo
Javatpoint Logo

C# SortedSet<T>

C# SortedSet class can be used to store, remove or view elements. It maintains ascending order and does not store duplicate elements. It is suggested to use SortedSet class if you have to store unique elements and maintain ascending order. It is found in System.Collections.Generic namespace.

C# SortedSet<T> example

Let's see an example of generic SortedSet<T> class that stores elements using Add() method and iterates elements using for-each loop.

Output:

Ankit
Irfan
Peter
Sonoo

C# SortedSet<T> example 2

Let's see another example of generic SortedSet<T> class that stores elements using Collection initializer.

Output:

Ankit
Irfan
Peter
Sonoo
Next TopicC# Stack





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA