main.cs127 chars6 lines
In this code block, we declare a variable sum
to hold the sum of the numbers. We then use a for
loop to iterate over the numbers from 1 to 10, and use the +=
operator to add each number to the sum
variable. Finally, we print out the result using the Console.WriteLine
method. This is an example of using control flow statements, arithmetic operators, and variables in C#.
gistlibby LogSnag