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); 

See Also
Related

Arrays

Documentation

List(T) Class - MSDN

Add to Slack

< Arrays   |   Dictionaries >

© 2019 SyntaxDB. All Rights Reserved.