I am just new in programming so excuse me for this 'easy' question.
I have a array list which have negative and positive numbers. It's in C#. I want to write on console, first negative number in this array list. How can do it? I tried a few things but it's writing all negative numbers or only the last negative number. I can't write the first one. Can anyone help me, please?
Here is my example of code :
int[] numbers = new int[] {13, 22, -5, 94, 66, -38, 41, -79, -1, 53};
int[] firstminus = new int[1];
for (int i = 0; i < 10; i++)
{
if (numbers[i] < 0)
firstminus[0] = numbers[i];
}
Console.WriteLine(firstminus[0]);
Console.ReadLine();