Hello dear,
In C# when you declare an array, you should specify items count. for example:
Code:
int[] iArray = new int[20];
because you dont have specified length of array, you get error.
when you dont know length of array, you can resize the array.
or you can use generic lists:
Code:
using System;
namespace Wrox.JackFeng{
class Order{
public Order(){}
public void OrderNumber(List<int> iArray){
foreach(int val in iArray){
Console.Write(val+'\t');
}
}
}
}
using Wrox.JackFeng
namespace Wrox.CadeFeng
{
class Program{
static void Main(){
const string sSuggestion="Please input some Number form(0-100)!";
string sNum = string.Empty;
List<int> iArray = new List<int>;
Console.WriteLine(sSuggestion);
while(1){
sNum = Console.ReadLine();
iArray.Add(Convert.ToInt32(sNum));
if(Convert.ToInt32(sNum)==0)
break;
}
Order Order_ = new Order();
Order_.OrderNumber(iArray);
}
}
}
click Thanks if it helps