0

# How can i count and summarize different integer values in c#?

So i have a lot of values like a1 = 0, a2 = 2 ... a40 = 231000 (There is no sequence beetween them so there is no way to count them with any formula). I need to make a cycle with them and count them depending on number in UpDownForm. If UpDownForm.Value = 5 for example, then i need to summarize a1+a2+a3+a4+a5 which will be the answer. How can i do it without mentioning all values everytime? Im thinking about: While (UpDownForm.Value != x(5 in example)). But i cant understand what to do afterwards.

0 Answers