Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What is the difference between list and dictionary in C#?
Dictionary is a collection of keys and values in C#. Dictionary<TKey, TValue> is included in the System.Collection.Generics namespace. Dictionary is a generic type and returns an error if you try to find a key which is not there.
List collection is a generic class and can store any data types to create a list.
A list is a group of items −
List<string> myList = new List<string>() {
"Maths",
"English",
" Science"
};
Dictionary is a set of key-value pairs.
Dictionary<string, int> d = new Dictionary<string, int>();
d.Add("squash", 1);
d.Add("football", 2);
d.Add("rugby", 3);
Looping is easier and faster in a list and access element using index easily with a List.
Advertisements
