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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.