Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Class1
- {
- private int counter = 0; // this variable tracks where in the array we are.
- private int[] numberArray = new int[10];
- // this just fills out the number array with 0-9
- public void setup()
- {
- for (int i = 0; i < 10; i++)
- {
- numberArray[i] = i;
- }
- }
- // this is where the magic actually happens
- public void add()
- {
- // here is where you would get some user input etc
- int userInput = int.Parse(Console.ReadLine());
- // and this is where we use that input.
- numberArray[counter] = userInput;
- // and then we increase the counter variable so that it references the next member of the array
- counter++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement