So I'm working on a library management system and I want to be able to delete both authors and book titles. By removing the author the program would remove every book by that author meanwhile the book title would only remove that specific book. However, I am kind of struggling as to how I would do this. Any help would be appreciated. Btw, "namn" = title and "författare" = author.
class Bok
{
public string ID
{ get; set; }
public int tempID;
public string Författare
{ get; set; }
public string namn
{ get; set; }
public int BokCount;
public int x;
}
class Program
{
static List<Bok> BokLista = new List<Bok>();
static List<BorrowDetails> borrowList = new List<BorrowDetails>();
static Bok Bok = new Bok();
static BorrowDetails borrow = new BorrowDetails();
//Menyn och startsidan till programmet
static void Main(string[] args)
{
using (StreamReader readFile = new StreamReader("bokfil.txt"))
{
string s;
while ((s = readFile.ReadLine()) != null)
{
Bok Bok = new Bok();
string[] BokData = s.Split(',');
Bok.Författare = BokData[0];
Bok.namn = BokData[1];
BokLista.Add(Bok);
}
readFile.Close();
}
public static void RaderaBok()
{
Console.Write("Mata in en författare eller boktitel som du vill radera: ");
string del = Console.ReadLine();
foreach (Bok b in BokLista)
{
if (b.Författare.Equals(del))
BokLista.Remove(Bok);
}
}