Create a C# app to do just that! Use a loop to display all positive integers up to 100 in a listbox when you enter a“Count by” number(e.g., 2, 3, 5, 10, etc.) in a textbox and click the Calculate button or press the Enter key. Think carefully about how to initialize and increment your counter variable in your loop. Remember, you can set a breakpoint (red dot) in your code to help debug it, if needed.
Additionally, display the sum of all of the listbox values in a label. For example, if your app counts by10’s, the sumshould be 550 (Figure 1). Declare and initialize asumvariable to zero, since it will serve as an accumulator variable. Add this logic to the code for the loop already in the Calculate button event handler. Clear the listbox before entering the loop.
Thirdly, use an Exit button or Escape to exit the app with confirmation.
Not required:
Input validation
Selecting all input text upon clicking or tabbing (.Click and .Enter methods, respectively)
Automatically clearing of output controls upon new input
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here