Language
Version: 5
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
Strings
Variables
Lists in C#
Lists are like arrays, but more flexible. They are mutable and can be dynamically sized.
Syntax
///the { } and initial values are optional
List<GenericDataType> listName = new List<GenericDataType>() {value1, value2};
///add a value
listName.add(value);
Notes
The generic data types can contain primitive types or types like objects.
Example
List<double> grades = new List<double>{95.0}; //declaring an array of size 2
grades.add(85.3);