This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Access individual item using indexer | |
List<int> numbers = new List<int>() | |
{ 1, 2, 5, 7, 8, 10 }; | |
Console.WriteLine(numbers[0]); // prints 1 | |
Console.WriteLine(numbers[1]); // prints 2 | |
Console.WriteLine(numbers[2]); // prints 5 | |
Console.WriteLine(numbers[3]); // prints 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<int> primeNumbers = new List<int>(); | |
primeNumbers.Add(1); | |
primeNumbers.Add(3); | |
primeNumbers.Add(5); | |
primeNumbers.Add(7); | |
var cities = new List<string>(); | |
cities.Add("NewYork"); | |
cities.Add("London"); | |
cities.Add("Mumbai"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Access individual item using indexer | |
int firstElement = (int) arlist[0]; | |
string secondElement = (string) arlist[1]; | |
//using var keyword without explicit casting | |
var firstElement = arlist[0]; | |
var secondElement = arlist[1]; | |
//update elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Adding elements | |
var arlist = new ArrayList(); | |
arlist.Add(1); | |
arlist.Add("Bill"); | |
arlist.Add(" "); | |
arlist.Add(true); | |
arlist.Add(4.5); | |
arlist.Add(null); |
NewerOlder