Code Flashcards
1
Q
Declare Array
A
int[] array1 = new int[5]; To declare size
// declare and assign values
int[] array3 = { 1, 2, 3, 4, 5, 6 };
// Longer syntax.
int[] array2 = new int[] { 1, 3, 5, 7, 9 };
2
Q
Declare a list
A
List parts = new List();
3
Q
check if value is key in dictionary
A
d.ContainsKey[value]
4
Q
Declare List
A
Dictionary numberNames = new Dictionary();
5
Q
Add key to dictionary
A
dictionary.Add(“Key”, “Value”);
dictionary.TryAdd(“Key”, “Value); //doesn’t throw exception if fails