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 a list and an array in C#?
An array stores a fixed-size sequential collection of elements of the same type, whereas list is a generic collection.
To define a List −
List<string7gt; myList = new List<string>();
To set elements in a list, you need to use the Add method −
myList.Add("Audi");
myList.Add("BMW");
myList.Add("Chevrolet");
myList.Add("Hyundai");
To define Arrays −
int[] arr = new int[5];
To initialize and set elements to Arrays −
int[] arr = new int[5] {23, 14, 11, 78, 56}; Advertisements
