I HAVE TWO LISTS AND I AM LOOKING TO SUM THE VALUES IN THEM. I HAVE TRIED SO MANY DIFFERENT WAYS. THIS IS WHAT I HAVE SO FAR:

for (int l = 1; l < list1.Count; l++)
            {

                string[] lineValues = list1[l].Split(',');

                float intValue = float.Parse(lineValues[l]);

                for (int k = 0; k < intValue; k++)
                {
                    float sum = 0.0F;
                    float Total = sum + intValue;
                    Console.Write(Total);
                }

ANY HELP WOULD BE BRILLIANT THANK YOU

Try this code

for (int l = 1; l < list1.Count; l++)
            {

                string[] lineValues = list1[l].Split(',');

                //float intValue = float.Parse(lineValues[l]);
                float sum = 0.0F;
                for (int k = 0; k < lineValues.Length; k++)
                {
                    
                   // float Total = sum + intValue;
                     sum+=float.Parse(lineValues[k]);
                     }
Console.Write(sum);
}

Edited 5 Years Ago by abelLazm: n/a

This question has already been answered. Start a new discussion instead.