using System;
public class Search {
public static void Main() {
int[] nums = new int[10];
int val;
bool found = false;
// give nums some values
for(int i = 0; i < 10; i++)
nums[i] = i;
val = 5;
// 通过foreach语句在nums数组中查找指定元素
foreach(int x in nums) {
if(x == val) {
found = true;
break;
}
}
if(found)
Console.WriteLine("Value found!");
}
}