C#C
C#13mo ago
dfsdfdsfsdf

how do i add the "remove task" thing?

https://hatebin.com/qkmmhnqzmt

using System.Collections;
using System.ComponentModel.Design;
using System.Data.Common;
using System.Diagnostics;
using System.Formats.Tar;
using System.Xml.Serialization;
string task = null;
string input;
string List = null;
int TaskCount = 0;
string taskprevious = "";


Console.WriteLine("Welcome to the To Do List!");
while (true)
{
Console.WriteLine(List);
Console.WriteLine("Type 'a' to add a task 'b' to remove a task 'c' to modify a task and 'd' to exit");
while (true)
{
input = Console.ReadLine();
if (input == "a"input == "c"||input == "d")
{
break;
}
else
{
Console.WriteLine("Invalid input.");
}
}
TextWriter tw = new StreamWriter("SavedGame.txt");


switch (input)
{
case "a":
{
TaskCount++;
Console.Write($"{TaskCount}. ");
task = Console.ReadLine();
Console.Clear();
Console.WriteLine("Changes applied!");
tw.WriteLine(TaskCount);
tw.WriteLine($"{TaskCount}. {task}");
tw.Close();
break;
}
case "b":
{
TaskCount --;
Console.WriteLine("Which Task do you want to remove? ('1' for task 1, '2'for task 2 etc..)");
while(true)
{
string answer = Console.ReadLine();
if(int.TryParse(answer, out int answer1)&&(answer1 <= 5))
{
break;
}
else
{
Console.WriteLine("Invalid Input!");
}
}

break;
}




}
for (int i = 0;i < TaskCount;i++)
{

TextWriter tw1 = new StreamWriter("SavedGame.txt");
tw1.WriteLine(List);
tw1.WriteLine($"{i + 1}.{task}");
tw1.Close();



}

TextReader tr1 = new StreamReader("SavedGame.txt");
List = tr1.ReadToEnd();
tr1.Close();

if (input == "d")
break;
}
Was this page helpful?