Brand new to C#, this is so confusing and my code is probably not as neat as some would want. Bear with me I'm learning.
I have a list of 'Items' called 'shoppingList'.
When the 'alphabetical' button is clicked, I want to rearrange the items in 'shoppingList' by 'Name' that is in the 'Item' class. Once the list is rearranged, the list is redrawn on the form.
I know there may be a solution on here already, but after trying so many of them I just believe my knowledge is not enough. Please use baby speak with me if you still know it. Happy to provide any more info also. Thank you in advance
public partial class Form1:Form{
List<Item> shoppingList = new List<Item>() { };
}
public class Item{
public Item(string Name, int Amount)
{
this.name = Name;
this.amount = Amount;
}
public string getname() { return name; }
public int getamount() { return amount; }
public int amount;
public string name;
}
private void alphabetical_Click(object sender, EventArgs e)
{
//What to put here?
ProcessAndDrawShoppingList();
}