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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Declare a list

A

List parts = new List();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

check if value is key in dictionary

A

d.ContainsKey[value]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Declare List

A

Dictionary numberNames = new Dictionary();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Add key to dictionary

A

dictionary.Add(“Key”, “Value”);
dictionary.TryAdd(“Key”, “Value); //doesn’t throw exception if fails

How well did you know this?
1
Not at all
2
3
4
5
Perfectly