'How do i perform operations on a structures field?

I im currently having an issue with when performing an operation with my structure. On form load, I am loading a comma delimited file with 6 indexes then using a 2d array i display the structured list's field to a grid view cell.

In the last for loop, perform the operation using my total field?

{
    public partial class Form1 : Form
    {
        public struct Costomers
        {
            public string firstN;
            public string lastN;
            public string address;
            public string item;
            public double price;
            public int quantity;
            public double total;
        }
        public Form1()
        {
            InitializeComponent();
        }

        List<Costomers> consumers = new List<Costomers>();

        private void Form1_Load(object sender, EventArgs e)
        {
            var inputfile = File.ReadAllLines("customers.txt");

            for (int i = 0; i < inputfile.Length; i++)
            {
                var SplitArr = inputfile[i].Split(',');

                // next declare a new instace of costomers
                Costomers ConsumerInfo = new Costomers();

                // the ConsumerInfo object now contains all of the fields i declared in the structer.
                // next i want to access the Objects fields and assign them
                ConsumerInfo.firstN = SplitArr[0];
                ConsumerInfo.lastN = SplitArr[1];
                ConsumerInfo.address = SplitArr[2];
                ConsumerInfo.item = SplitArr[3];
                ConsumerInfo.price = Convert.ToDouble(SplitArr[4]);
                ConsumerInfo.quantity = Convert.ToInt32(SplitArr[5]);
                //ConsumerInfo.total = consumers[i].price * consumers[i].quantity;

                consumers.Add(ConsumerInfo);
            }
            // Next i need to disply each field in the grid view
            // i will resue my code from section F to do this.
            for (int i = 0; i < consumers.Count; i++)
            {
                dgInfo.Rows.Add();
                dgInfo[0, i].Value = consumers[i].firstN;
                dgInfo[1, i].Value = consumers[i].lastN;
                dgInfo[2, i].Value = consumers[i].address;
                dgInfo[3, i].Value = consumers[i].item;
                dgInfo[4, i].Value = consumers[i].price;
                dgInfo[5, i].Value = consumers[i].quantity;
            }
            // next in a seperat for loop i need too mutiply the price by the quantity 

            for (int i = 0; i < consumers.Count; i++)
            {
                Costomers totalPrice = new Costomers();

                totalPrice.total = consumers[i].price * consumers[i].quantity;

                dgInfo[6,i].Value = totalPrice.total;
            }
        }
    }
}```

Second, because the file i load does not contain a index for total; how to i display the total in its own column?

Text file as shown below:

The, Batman, 123 Gotham Drive, bat belt, 193.82,17
The, Joker, 12432 Joker Way, Bat Spray, 19.99, 1022
Cat, Women, 8787 Meow St., Kibbles, 9.99, 4700
The, Penguin, 17 Waddel Ave., pointy cigarettes, 24.99, 51700
sidekick, Robin, 123 Gotham Drive, junior bat belt, 67.80, 10000
Adam, West, 1782 Hollywood Dr., hasbeen kit, 10305018.18, 1




 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source