C# APIs Flashcards

1
Q

Determine the length of a List<>

A

List.Count() does not modify

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

Add ab item to the end of a List<>

A

List.Add() in place modification, does not return

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

index the i’th element of a List

A

List[i] returns the value but also allows modification or List.ElementAt(i) returns the value

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

Remove element from List at i

A

List().RemoveAt(i), in place modification

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

Reverse a List

A

List.Reverse() in place modification, returns void

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

Given a List, merge all of the string elements into a single string

A

String.Join(“ “, List())

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

Copy a List to a new T[]

A

List.ToArray()

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

Given List, find the first occurrence of someT, start searching at index idx

A

List.IndexOf(someT, idx)

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

Given List append another List to the end of it

A

List.Append(List otherList)

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

Given Dictionary, determine if the key someKey exists

A

Dictionary.ContainsKey(someKey)

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

Given Dictionary determine if someValue exists

A

Dictionary.ContainsValue(someValue)

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

Return all of the keys in a dictionary as an IEnumerable

A

Dictionary.Keys

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

Loop over all of the keys in a Dictionary

A

foreach (int key in Dictionary.Keys)

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

Given a String, replace all instances of char1 with char2

A

String.Replace(char1, char2)

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

Given a String, replace all instances of string1 with string2

A

String.Replace(string1, string2)

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

Given a someChar which represents a number e.g. ‘1’, ‘2’, ‘3’

Get the numeric value of that char

A

Char.GetNumericVBalue(someChar)

.GetNumericValue is a static member method of the Char class

17
Q

Given someString, convert to an int

A

int32.Parse(someString)

18
Q

Given someString, get the substring of length L from idx1 to idx1 + L

A

someString.Substring(idx1, L)

19
Q

Given someString, insert otherString starting at index idx

A

someString.Insert(idx, otherString)