What is the Values property of SortedList class in C#?

CsharpProgrammingServer Side Programming

Firstly, declare the SortedList class −

SortedList list = new SortedList();

Now add the values −

list.Add("S1", "Wallets");
list.Add("S2", "Sunglasses");
list.Add("S3", "Backpacks");

The following is the code to work with Values property of SortedList class −

Example

 Live Demo

using System;
using System.Collections;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         SortedList list = new SortedList();

         list.Add("S1", "Wallets");
         list.Add("S2", "Sunglasses");
         list.Add("S3", "Backpacks");

         foreach (string value in list.Values) {
            Console.WriteLine(value);
         }
      }
   }
}

Output

Wallets
Sunglasses
Backpacks
raja
Published on 08-Aug-2018 10:47:26
Advertisements