文件名称:C#数组的查找实例源码
文件大小:38KB
文件格式:ZIP
更新时间:2018-08-04 02:52:04
数组查询
C#数组的查找实例源码 int find(int[] array, int value) { if (array==null || array.Length==0) { return -1; } else { int index = 0; for (; index < array.Length; index++) { if (value == array[index]) { return index; } } } return -1; } string find2(int[,] array, int value) { string s = ""; if (array == null || array.Length == 0) { return "-1"; } else { int m = array.GetLength(0); int n= array.GetLength(1); for ( int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (value == array[i,j]) { //相同值都可以查找到 s=s+ " array[" + i + "," + j + "]=" + array[i, j]; } } } return s; } }
【文件预览】:
WindowsApplication3
----WindowsApplication3()
--------Form1.cs(3KB)
--------bin()
--------obj()
--------Properties()
--------Program.cs(478B)
--------Form1.Designer.cs(3KB)
--------Form1.resx(6KB)
--------WindowsApplication3.csproj(3KB)
----WindowsApplication1.suo(28KB)
----WindowsApplication1.sln(946B)