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


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 20-Jun-2020

57 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements