23 Mart 2009 Pazartesi

while ifadesi

using System;
class Test
{
static int Find(int value, int[] arr) {
int i = 0;
while (arr[i] != value) {
if (++i > arr.Length)
throw new ArgumentException();
}
return i;
}
static void Main() {
Console.WriteLine(Find(3, new int[] {5, 4, 3, 2, 1}));
}
}

Hiç yorum yok:

Yorum Gönder