Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the Capacity property of SortedList class in C#?
The capacity property in SortedList class has the maximum size of the SortedList.
The default capacity of a SortedList is 16.
You can try to run the following the code to implement Capacity property of SortedList class in C# −
Example
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
SortedList s = new SortedList();
s.Add("S1", "Maths");
s.Add("S2", "Science");
s.Add("S3", "English");
s.Add("S4", "Economics");
Console.WriteLine("Capacity = " + s.Capacity);
}
}
}
Output
Capacity = 16
Above we first added elements to the SortedList.
SortedList s = new SortedList();
s.Add("S1", "Maths");
s.Add("S2", "Science");
s.Add("S3", "English");
s.Add("S4", "Economics");
Then we found out the capacity −
s.Capacity
Advertisements