C# Flashcards
How to create a string variable input, list and int input.
List<string> listOfStrings = new List<string>();</string></string>
string variableName;
variableName = Console.ReadLine();
int a = Convert.ToInt32(Console.ReadLine());
How to display everything in a list
foreach (string month in listOfStrings)
{
Console.WriteLine(month);
}
How to add multiple things to a list
listOfStrings.AddRange(new string[]
{
“Jenna Doe”,
“Another Doe”
});
How to add/remove one thing from a list
listOfStrings.Add(“Original Doe”);
listOfStrings.Remove(“Original Doe”);
How to remove multiple thing from a list that fit criteria
listOfStrings.RemoveAll(name =>
{
if (name.StartsWith(“J”))
return true;
else
return false;
});