C# SortedList Tutorial with Examples

C# SortedList Tutorial with Examples

Today, We want to share with you C# SortedList Tutorial with Examples.
In this post we will show you SortedList in C#.Net with example and description, hear for C# Generic SortedList with Programming Example we will give you demo and example for implement.In this post, we will learn about Hashtable and SortedList in C# with an example.

Introduction: SortedList in C#.Net

In this post, we will learn about SortedList in C#.Net with an example.The SortedList<> class represents a collection of key/value pairs that are sorted by key. A sorted list is a combination of an array and a hash table.

READ :  Responsive Navigation Menu CSS Free download

Methods :

1. Add(object key, object value)

This method is used to

2. Remove(object key)

This method is used to removes element with the specified key.

1. RemoveAt(int index)

This method is used to removes element at the specified index.

1. Contains(object key)

E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

This method is used to checks whether specified key exists in SortedList.

1. Clear()

This method is used to removes all the elements from SortedList.

Now, Create Console Application in Visual Studio and write below line of code.

using System;
using System.Collections;

namespace ConsoleDemo
    class Program
        static void Main(string[] args)
            SortedList _SiteList = new SortedList();

            _SiteList.Add("001", "pakainfo.Com");
            _SiteList.Add("002", "infinityknow.com");
            _SiteList.Add("003", "W3pSchool.Com");   

            foreach (string k in _SiteList.Keys)
                Console.WriteLine(k + ": " + _SiteList[k]);

Read :

READ :  C# Sorted Dictionary Tutorial with Examples


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about C# SortedList Class.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.