

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 are the differences between a dictionary and an array in C#?
Dictionary
Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.
To declare a Dictionary −
IDictionary<int, int> d = new Dictionary<int, int>();
To add elements −
IDictionary<int, int> d = new Dictionary<int, int>(); d.Add(1,97); d.Add(2,89); d.Add(3,77); d.Add(4,88);
Array
Array stores a fixed-size sequential collection of elements of the same type. It consists of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
To define Arrays −
int[] arr = new int[5];
To initialize and set elements to Arrays.
int[] arr = new int[10] {3, 5, 35, 87, 56, 99, 44, 36, 78};
- Related Questions & Answers
- What are the differences between a list collection and an array in C#?
- What are the differences between a multi-dimensional array and jagged array?
- What are the differences between a class and an interface in Java?
- What are the differences between an application and an applet in Java?
- What are the differences between an Integer and an int in Java?
- What are differences between a gated community and an apartment?
- What are the differences between C++ and Java?
- What are the differences between C and Java?
- What are the differences between holography and photography?
- What are the differences between lodash and underscore?
- What are the differences between solvency and liquidity?
- What are the differences between IPO and FPO?
- What are the differences between Flutter and Xamarin?
- What are the differences between Telegram and WhatsApp?
- What are the differences between FDMA and CDMA?
Advertisements