
- 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
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 Articles
- 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 Python and an Anaconda?
- What are the differences between an Integer and an int in Java?
- What are the differences between an application and an applet in Java?
- What are differences between a gated community and an apartment?
- What are the differences between Zygote and a Foetus?
- What are the Differences Between a Team and a Group?
- What are the differences between a mixture and a solution?
- What are the differences between an Exception class and an Error class in Java?\n
- What are the differences between a class and struct in C#?
- What are the differences between a class and a structure in C#?
- What are the differences between a MouseListener and a MouseMotionListener in Java?
- What are the differences between a JComboBox and a JList in Java?

Advertisements