Objects - Arrays Flashcards

1
Q

What is an array?

A

A numbered list of items.

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

What is an index?

A

It is an item’s number in the array.

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

What will the sixth item on a list’s index be?

A
  1. Remember that we use 0 based counting in OOP.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you create an array?

A

1 - specify the type of data that you want to store in the array (string, int etc)

#2 follow the type declaration with square brackets : 
string[]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What will be returned if you dont tell the array what you want the items to contain?

A

null in each indices that hasn’t been assigned a value.

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

How do you assign values to specific indices?

A

arrayName[index # you want to assign] = “Value you want to give it.”;

favThings [0] = “First item.”; will assign “First item.” to the first indices.

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

How do you shorten the syntax of array creation?

A

You can shorten it to this:

string[] nameOfArray = {“first”, “second”, “third”};

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

How can you find out the length of an array?

A

nameOfArray.Length

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

What is a turnairy if statement?

A

Its a bit of syntactic sugar that combines an if/else into one statement:

return(pathStep , _path.Length) ? _path[pathStep] : null;

put a question mark after the conditions, separate the if and else with a :

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