Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C# Data Types
  • C# Decision Making
  • C# Methods
  • C# Delegates
  • C# Constructors
  • C# Arrays
  • C# ArrayList
  • C# String
  • C# Tuple
  • C# Indexers
  • C# Interface
  • C# Multithreading
  • C# Exception
Open In App
Next Article:
C# | Getting the keys in a SortedList object
Next article icon

C# | Getting the list of Values of a SortedList object

Last Updated : 01 Feb, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
SortedList.GetValueList Method is used to get the list of keys in a SortedList object. Syntax:
public virtual System.Collections.IList GetValueList ();
Return Value: It returns an IList object containing the values in the SortedList object. Below programs illustrate the use of above-discussed method: Example 1: CSharp
// C# code for getting the values // in a SortedList object using System; using System.Collections;  class Geeks {      // Main Method     public static void Main(String[] args)     {          // Creating a SortedList of integers         SortedList mylist = new SortedList();          // Adding elements to SortedList         mylist.Add("1", "C++");         mylist.Add("2", "Java");         mylist.Add("3", "DSA");         mylist.Add("4", "Python");         mylist.Add("5", "C#");          // taking an IList and         // using GetValueList method         IList vlist = mylist.GetValueList();          // Prints the list of keys         Console.WriteLine("Value Stored in SortedList:");          // will print the values in Sorted Order         for (int i = 0; i < mylist.Count; i++)             Console.WriteLine(vlist[i]);     } } 
Output:
  Value Stored in SortedList:  C++  Java  DSA  Python  C#  
Example 2: CSharp
// C# code for getting the values // in a SortedList object using System; using System.Collections;  class Geeks {      // Main Method     public static void Main(String[] args)     {          // Creating a SortedList of integers         SortedList mylist = new SortedList();          // Adding elements to SortedList         mylist.Add("First", "Ram");         mylist.Add("Second", "Shyam");         mylist.Add("Third", "Mohit");         mylist.Add("Fourth", "Rohit");         mylist.Add("Fifth", "Manish");          // taking an IList and         // using GetValueList method         IList vlist = mylist.GetValueList();          // Prints the list of keys         Console.WriteLine("Value Stored in SortedList:");          // will print the values in Sorted Order         for (int i = 0; i < mylist.Count; i++)             Console.WriteLine(vlist[i]);     } } 
Output:
  Value Stored in SortedList:  Manish  Ram  Rohit  Shyam  Mohit  
Note:
  • The returned IList object is a read-only view of the values of the SortedList object. Modifications made to the underlying SortedList are immediately reflected in the IList.
  • The elements of the returned IList are sorted in the same order as the values of the SortedList.
  • This method is similar to the Values property but returns an IList object instead of an ICollection object.
  • This method is an O(1) operation.
Reference:
  • https://docs.microsoft.com/en-us/dotnet/api/system.collections.sortedlist.getvaluelist?view=netframework-4.7.2

Next Article
C# | Getting the keys in a SortedList object

K

Kirti_Mangal
Improve
Article Tags :
  • C#
  • CSharp-method
  • CSharp-Collections-Namespace
  • CSharp-Collections-SortedList

Similar Reads

  • C# | Getting the Values in a SortedList object
    SortedList.Values Property is used to get the values in a SortedList object. Syntax: public virtual System.Collections.ICollection Values { get; } Property Value: An ICollection object containing the values in the SortedList object. Below programs illustrate the use of above-discussed property: Exam
    2 min read
  • C# | Getting the list of keys of a SortedList object
    SortedList.GetKeyList Method is used to get the list of keys in a SortedList object. Syntax: public virtual System.Collections.IList GetKeyList (); Return Value: It returns an IList object containing the keys in the SortedList object. Below programs illustrate the use of above-discussed method: Exam
    2 min read
  • C# | Getting index of the specified value in a SortedList object
    SortedList.IndexOfValue(Object) Method is used to get the zero-based index of the first occurrence of the specified value in a SortedList object. Syntax: public virtual int IndexOfValue (object value); Here, value is the Value which is to be located in the SortedList object. The value can be null. R
    3 min read
  • C# | Getting the keys in a SortedList object
    SortedList.Keys Property is used to get the keys in a SortedList object. Syntax: public virtual System.Collections.ICollection Keys { get; } Property Value: An ICollection object containing the keys in the SortedList object. Below programs illustrate the use of above-discussed property: Example 1: /
    2 min read
  • C# | Getting the value at the specified index of a SortedList object
    SortedList.GetByIndex(Int32) Method is used to get the value at the specified index of a SortedList object. Syntax: public virtual object GetByIndex (int index); Here index is the zero-based index of the value to get. Return Value: It returns the value at the specified index of the SortedList object
    2 min read
  • C# | Getting the key at the specified index of a SortedList object
    SortedList.GetKey(Int32) Method is used to get the key at the specified index of a SortedList object. Syntax: public virtual object GetKey (int index); Here, index is the zero-based index of the key to get. Return Value: This method returns the key at the specified index of the SortedList object. Ex
    2 min read
  • C# | Getting the index of the specified key in a SortedList object
    SortedList.IndexOfKey(Object) Method is used to get the zero-based index of the specified key in a SortedList object. Syntax: public virtual int IndexOfKey (object key); Here, key is the Key which is to be located in the SortedList object. Return Value: This method returns the zero-based index of ty
    3 min read
  • C# | Check if a SortedList object contains a specific value
    SortedList class is a collection of (key, value) pairs which are sorted according to keys. Those pairs can be accessible by key and as well as by index(zero-based indexing). This comes under System.Collections namespace. SortedList.ContainsValue(Object) method is used to check whether a SortedList o
    2 min read
  • C# | Copying the SortedList elements to an Array Object
    SortedList.CopyTo(Array, Int32) Method is used to copy SortedList elements to a one-dimensional Array object, starting at the specified index in the array. Syntax: public virtual void CopyTo (Array array, int arrayIndex); Parameters: array: It is the one-dimensional Array object that is the destinat
    2 min read
  • How to create a shallow copy of SortedList Object in C#
    SortedList.Clone() Method is used to create a shallow copy of a SortedList object. Syntax: public virtual object Clone(); Return Value: It returns a shallow copy of the SortedList object. The type of returned value will be Object. Note: A shallow copy of a collection copies only the elements of the
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences