Hello everyone. So, i'm just trying to make a simple console application so that anytime you enter a number, it'll enter it into the array, but when you enter "done" it will load & output all of the numbers that you entered. The problem is, I don't know how to continue to get the numbers, I can only get the first input. If you know what i'm talking about and how to fix this, please help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication2
{
class Program
{
static public void Main ( ) {
ArrayList numbers = new ArrayList();
numbers = new ArrayList();
Console.Title = "Numbers";
Console.WriteLine ( "Enter in some numbers. When you're finished, type \"done\"");
String text = Console.ReadLine();
if (text.ToLower() != "done") {
numbers.Add(Convert.ToInt32(text));
} else {
string numbs = "";
for (int i = 0; i < numbers.Count; i++) {
if (i != 0){
numbs = numbs + ", " + numbers[i];
}else{
numbs = numbers[i] + "";
}
}
Console.WriteLine("You entered: " + numbs);
}
Console.ReadLine();
}
}
}
Thanks.
- Braydon
No comments:
Post a Comment