class ToDoList {
public static void toDO() {
List<string[]> addEntry = [];
bool toDoLoop = true;
while (toDoLoop) {
Clear();
WriteLine("\n\t\tHere is your to do list!");
for (int i = 1; i < addEntry.Count; i++)
{
WriteLine($"\n\t\tTo Do {i}: {addEntry[i][0]}");
}
Write("\n\t\t[N]ew Entry\t[E]xit\t");
string? userChoice = ReadLine();
switch (userChoice)
{
case "n":
case "N":
Write("\n\t\tAdd New Entry: ");
string?[] newToDo = new string[1];
newToDo[0] = ReadLine();
if (newToDo.Length == 0) {
WriteLine("\n\t\tEntries can't be null!");
}
else {
addEntry.Add(newToDo);
}
break;
case "e":
case "E":
Clear();
WriteLine("\n\n\t\tClosing To Do!");
toDoLoop = false;
break;
default:
Clear();
WriteLine("\n\t\tInvalid Entry!");
break;
}
}
}
}
I have tried a different variants with having the add entry inside both the if and the else, but i don't get it to work. Am i thinking completely wrong or am i at least on the right path?
if (newToDo[0] == "")
if (newToDo[0] != )
if (newToDo[0] is null)
if (newToDo[0] is not null)
if (!string.IsNullOrEmpty(newToDo[0]))