
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Getting the value at the specified index of a SortedList object in C#
To get the value at the specified index of a SortedList object, the code is as follows −
Example
using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("A", "Jacob"); list.Add("B", "Sam"); list.Add("C", "Tom"); list.Add("D", "John"); list.Add("E", "Tim"); list.Add("F", "Mark"); list.Add("G", "Gary"); Console.WriteLine("Value at index 2 = "+list.GetByIndex(2)); Console.WriteLine("Value at index 5 = "+list.GetByIndex(5)); Console.WriteLine("Value at index 6 = "+list.GetByIndex(6)); } }
Output
This will produce the following output −
Value at index 2 = Tom Value at index 5 = Mark Value at index 6 = Gary
Example
Let us see another example −
using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add(1, "One"); list.Add(2, "Two"); list.Add(3, "Three"); list.Add(4, "Four"); list.Add(5, "Five"); Console.WriteLine("Value at index 0 = "+list.GetByIndex(0)); } }
Output
This will produce the following output −
Value at index 0 = One
- Related Articles
- Getting index of the specified value in a SortedList object in C#
- Getting the key at the specified index of a SortedList object in C#
- Getting the index of the specified key in a SortedList object in C#
- Remove from the specified index of a SortedList in C#
- Getting the keys in a SortedList object C#
- Getting the Values in a SortedList object in C#
- Getting the list of keys of a SortedList object in C#
- Getting the list of Values of a SortedList object in C#
- Python Pandas - Fill NaN values with the specified value in an Index object
- Searching the index of specified object in Collection in C#
- Copy StringCollection at the specified index of array in C#
- Replace an element at a specified index of the Vector in Java
- Get or set the value associated with specified key in SortedList in C#
- Remove the element at the specified index of the ArrayList in C#
- Insert at the specified index in StringCollection in C#

Advertisements