C# Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How to create a string variable input, list and int input.

A

List<string> listOfStrings = new List<string>();</string></string>

string variableName;
variableName = Console.ReadLine();

int a = Convert.ToInt32(Console.ReadLine());

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

How to display everything in a list

A

foreach (string month in listOfStrings)
{
Console.WriteLine(month);
}

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

How to add multiple things to a list

A

listOfStrings.AddRange(new string[]
{
“Jenna Doe”,
“Another Doe”
});

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

How to add/remove one thing from a list

A

listOfStrings.Add(“Original Doe”);
listOfStrings.Remove(“Original Doe”);

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

How to remove multiple thing from a list that fit criteria

A

listOfStrings.RemoveAll(name =>
{
if (name.StartsWith(“J”))
return true;
else
return false;
});

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