I changed some methods used previously, and I am wondering if I need to do the multiple for loops over and over again. How do I convert my arrays to lists to use in nested for loops?using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Threading.Tasks;using TwoWayAnova;namespace TwoWayAnovaTable{public partial class TwoWayAnovaTable : Form{    public TwoWayAnovaTable()    {        InitializeComponent();    }    private static readonly char[] Separators = { ',', ' ' };private static double _aTreatmentSumOfSquares;private static double _bTreatmentSumOfSquares;private static double _interactionSumOfSquares;    private static double _errorSumOfSquares;    private static double _sumOfSquares;    private static double _aMeanTreatmentSumOfSquares;    private static double _bMeanTreatmentSumOfSquares;    private static double _interactionMeanSumOfSquares;    private static double _meanErrorSumOfSquares;    private static double _aTreatmentDegreesOfFreedom;    private static double _bTreatmentDegreesOfFreedom;    private static double _interactionDegreesOfFreedom;    private static double _errorDegreesOfFreedom;    private static double _totalDegreesOfFreedom;    private static double _aTestStatistic;    private static double _bTestStatistic;    private static double _interactionTestStatistic;    private static double _aPValue;    private static double _bPValue;    private static double _interactionPValue;    private static void ProcessFile()    {        var lines = File.ReadLines(Data.csv);        var numbers = ProcessRawNumbers(lines);        var rowTotal = new List<double>();        var squareRowTotal = new List<double>();        var rowMean = new List<double>();        var totalElements = 0;        var totalInRow = new List<int>();        var rowTotalSquareByN = new List<double>();        var sumOfSquareOfBlock = new List<double>();        foreach (var values in numbers)        {            var sumOfRow = values.Sum();            rowTotal.Add(sumOfRow);            squareRowTotal.Add(values.Select(v => v * v).Sum());            rowMean.Add(sumOfRow / values.Count);            totalInRow.Add(values.Count);            totalElements += values.Count;            rowTotalSquareByN.Add(rowTotal.Select(r => r * r / values.Count).Sum());            sumOfSquareOfBlock = squareRowTotal - rowTotalSquareByN;        }        var grandTotal = rowTotal.Sum();   }    int aNum = 3, bNum = 3;        double[] totalSumPerBlock = new double[bNum];        double[] totalSumOfSquaresPerBlock = new double[bNum];        int[] blockTotalElements = new int[bNum];        double[] totalSquarePerBlockByN = new double[bNum];        double[] blockMean = new double[bNum];        double[] sumOfSquaresTotalOfBlock = new double[bNum];        for (int i = 0; i < bNum; i++)        {            for (int j = 0; j < aNum; j++)            {                totalSumPerBlock[i] += rowTotal[j + i * 3];                totalSumOfSquaresPerBlock[i] += squareRowTotal[j + i * 3];                blockTotalElements[i] += totalInRow[j + i * 3];                sumOfSquaresTotalOfBlock[i] += sumOfSquareOfBlock[j + i * 3];            }            totalSquarePerBlockByN[i] += totalSumPerBlock[i] * totalSumPerBlock[i] / blockTotalElements[i];            blockMean[i] = totalSumPerBlock[i] / blockTotalElements[i];        }        double[] grandTotalAllBlocks = new double[bNum];        double[] grandBlockSumOfSquares = new double[bNum];        int[] grandNumberOfElements = new int[bNum];        double[] grandSumOfSquares = new double[bNum];        double[] grandBlockSquaresSumByN = new double[bNum];        double[] grandBlockMean = new double[bNum];        double finalSum = 0;        double finalSumOfSquaresRow = 0;        int finalElements = 0;        double finalSumOfSquaresByN = 0;        double finalSumOfSquares = 0;        double finalMean = 0;        for (int i = 0; i < bNum; i++)        {            for (int j = 0; j < aNum; j++)            {                grandTotalAllBlocks[i] += rowTotal[i + 3 * j];                grandBlockSumOfSquares[i] += squareRowTotal[i + 3 * j];                grandNumberOfElements[i] += totalInRow[i + 3 * j];            }            grandBlockSquaresSumByN[i] = grandTotalAllBlocks[i] * grandTotalAllBlocks[i] / grandNumberOfElements[i];            grandBlockMean[i] = grandTotalAllBlocks[i] / grandNumberOfElements[i];            finalSum += grandTotalAllBlocks[i];            finalSumOfSquaresRow += grandBlockSumOfSquares[i];            finalElements += grandNumberOfElements[i];            finalSumOfSquaresByN = finalSum * finalSum / finalElements;            finalSumOfSquares = finalSumOfSquaresRow - finalSumOfSquaresByN;            finalMean = finalSum / finalElements;        }        for (int i = 0; i < numbers.Count; i++)        {            _errorSumOfSquares += sumOfSquareOfBlock[i];            _interactionSumOfSquares += rowTotalSquareByN[i];        }        for (int i = 0; i < bNum; i++)        {            _aTreatmentSumOfSquares += totalSquarePerBlockByN[i];            _bTreatmentSumOfSquares += grandBlockSquaresSumByN[i];            _interactionSumOfSquares = _interactionSumOfSquares - totalSquarePerBlockByN[i] - grandBlockSquaresSumByN[i];        }        _interactionSumOfSquares = (-1) * (_aTreatmentSumOfSquares - _bTreatmentSumOfSquares) + finalSumOfSquaresByN;        _aTreatmentSumOfSquares -= finalSumOfSquaresByN;        _bTreatmentSumOfSquares -= finalSumOfSquaresByN;        _sumOfSquares = _errorSumOfSquares + _bTreatmentSumOfSquares + _interactionSumOfSquares + _aTreatmentSumOfSquares;        _aTreatmentDegreesOfFreedom = aNum - 1;        _bTreatmentDegreesOfFreedom = bNum - 1;        _interactionDegreesOfFreedom = _aTreatmentDegreesOfFreedom * _bTreatmentDegreesOfFreedom;        _errorDegreesOfFreedom = (totalElements - 1) - _aTreatmentDegreesOfFreedom - _bTreatmentDegreesOfFreedom - _interactionDegreesOfFreedom;        _totalDegreesOfFreedom = totalElements-1;        _aMeanTreatmentSumOfSquares = _aTreatmentSumOfSquares / _aTreatmentDegreesOfFreedom;        _bMeanTreatmentSumOfSquares = _bTreatmentSumOfSquares / _bTreatmentDegreesOfFreedom;        _interactionMeanSumOfSquares = _interactionSumOfSquares / _interactionDegreesOfFreedom;        _meanErrorSumOfSquares = _errorSumOfSquares / _errorDegreesOfFreedom;        _aTestStatistic = TwoWayAnovaClass.CalculateTestStatistic(_aMeanTreatmentSumOfSquares,_meanErrorSumOfSquares);        _bTestStatistic = TwoWayAnovaClass.CalculateTestStatistic(_bMeanTreatmentSumOfSquares, _meanErrorSumOfSquares);        _interactionTestStatistic = TwoWayAnovaClass.CalculateTestStatistic(_interactionMeanSumOfSquares, _meanErrorSumOfSquares);        _aPValue = TwoWayAnovaClass.CalculatePValue(_aTestStatistic, _aTreatmentDegreesOfFreedom, _errorDegreesOfFreedom);        _bPValue = TwoWayAnovaClass.CalculatePValue(_bTestStatistic, _bTreatmentDegreesOfFreedom, _errorDegreesOfFreedom);        _interactionPValue = TwoWayAnovaClass.CalculatePValue(_interactionTestStatistic, _interactionDegreesOfFreedom, _errorDegreesOfFreedom);        TSS = _aTreatmentSumOfSquares.ToString();        ESS = _errorSumOfSquares.ToString();        BSS = _bTreatmentSumOfSquares.ToString();        ISS = _interactionSumOfSquares.ToString();        TotSS = _sumOfSquares.ToString();        TDF = _aTreatmentDegreesOfFreedom.ToString();        BDF = _bTreatmentDegreesOfFreedom.ToString();        IDF = _interactionDegreesOfFreedom.ToString();        EDF = _errorDegreesOfFreedom.ToString();        TotDF = _totalDegreesOfFreedom.ToString();        TMS = _aMeanTreatmentSumOfSquares.ToString();        BMS = _bMeanTreatmentSumOfSquares.ToString();        IMS = _interactionMeanSumOfSquares.ToString();        EMS = _meanErrorSumOfSquares.ToString();        FT = _aTestStatistic.ToString();        FBk = _bTestStatistic.ToString();        FIn = _interactionTestStatistic.ToString();        pT = _aPValue.ToString();        pBl = _bPValue.ToString();        pI = _interactionPValue.ToString();    }    private void button2_Click(object sender, EventArgs e)    {        ReadFile();        display();    }    private void display()    {        textBoxTSS.Text = TSS;        textBoxESS.Text = ESS;        textBoxISS.Text = ISS;        textBoxBSS.Text = BSS;        textBoxTotSS.Text = TotSS;        textBoxTDF.Text = TDF;        textBoxEDF.Text = EDF;        textBoxIDF.Text = IDF;        textBoxBDF.Text = BDF;        textBoxTotDF.Text = TotDF;        textBoxTMS.Text = TMS;        textBoxEMS.Text = EMS;        textBoxBMS.Text = BMS;        textBoxIMS.Text = IMS;        textBoxFT.Text = FT;        textBoxFB.Text = FBk;        textBoxFI.Text = FIn;        textBoxpT.Text = pT;        textBoxpB.Text = pBl;        textBoxpI.Text = pI;    }}}
Two-way ANOVA table
c#;performance;.net;statistics