I am trying to create selling feature where if you use the sell command and write one of the items you want to sell from your inventory(array) then it will remove the item from the array and add some money to your balance. How do I remove a specific string from an array? For example, I want to say that I want to remove the string "Carp" without specifying "inventory[0]".
long balance = 100;
string[] inventory = {"Carp", "Laptop", "Mobile"}
Console.WriteLine("What do you want to sell?"
string sellingItem = Console.ReadLine();
if(sellingItem.Equals("Carp")
{
Console.WriteLine("Selling Carp");
balance = balance+15;
//
}
I tried to search for solutions but none of them were able to full fil my criteria.