14,669,657 members
Rate this:
See more:
Hi all!

```static void Main(string[] args)
{
int[] numbers_in_array = { 5, 7, 4, 3, 2 };
Console.WriteLine(FunctionReturnMinimumValue(numbers_in_array));
}
static int FunctionReturnMinimumValue(int[] matrix)
{
int minimum = matrix[0];
for (int i = 0; i < matrix.Length; i++)
{
if (matrix[i] < minimum)
minimum = matrix[i];
}
return minimum;
}```

what i need here is to write numbers into array
i know how to do it with pre defined numbers like in this example, but
when i need to enter numbers into console that is the problem. :)

Dont know how to do it,
can anyone plz help me with this.
Thx
Posted

Rate this:

## Solution 2

Probably this can help. Its a snippet that creates an array depending on what you set on your `count `variable. And from there it loops (`count`) times to accept an input and adds it to the array.

```string x;
int count = 5;
int[] yourArray = new int[count];
for (int i = 0; i < count; i++)
{
yourArray[i] = Convert.ToInt32(x);
}```
Rate this:

## Solution 3

I would prefer to use a List<int> rather than an array. Try this little Console app

```class Program
{
static void Main(string[] args)
{
List<int> numbers = new List<int>();
bool IsDone = false;
do
{
Console.Write("Enter a number to add to the list, else enter any letter to continue: ");
if (result)
{
}
else
{
IsDone = true;
}
} while (IsDone == false);
Console.WriteLine("The Minimum Value in your list = {0}", FunctionReturnMinimumValue(numbers));
}
static int FunctionReturnMinimumValue(List<int> matrix)
{
int minimum = matrix[0];
for (int i = 0; i < matrix.Count - 1; i++)
{
if (matrix[i] < minimum)
minimum = matrix[i];
}
return minimum;
}
}```

Hope this helps
Rate this:

## Solution 1

try this..,

this code may helps you

```string strarray = "1,2,3,4,5,6,7";
string[] splitarr = strarray.Split(',');
Int32[] intarr = new Int32[splitarr.Length];
for (int innlop = 0; innlop < splitarr.Length; innlop++)
intarr[innlop] = Convert.ToInt32(splitarr[innlop]);```

user need to enter values with a delimiter(",")

thanks

thx...this helped a lot
Groulien 28-Apr-11 4:01am

If this solution worked for you, please use the 'Accept as solution' button.
Rajesh Anuhya 29-Apr-11 0:22am

how it's down voted??
walterhevedeich 29-Apr-11 0:41am

Voted 5 to counter.