0

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

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by abelLazm
0

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 by abelLazm: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.