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
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