111,129
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
int[,] a = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } };
public Program()
{
//依次输出数组中的所有数据
foreach (int temp in a)
{
Console.Write(temp + ",");
}
}
static void Main(string[] args)
{
Program p1 = new Program();
Console.ReadLine();
}
}
}
static void Main(string[] args)
{
int[,] a = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } };
int min = a[0, 0];
foreach (int e in a)
{
if (e < min)
min = e;
}
Console.WriteLine(min);
Console.ReadLine();
}
foreach(element_type element in element_collection)
{
//每个元素的值可以被更改,但是影响这个集合遍历的操作不能被执行,例如删除某个元素
do_something( element );
}
foreach(var element in element_collection)
....
for(int i = 0;i<lenght;i++)
....
int[,] a = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } };
public int GetMinValue(int[,] a)
{
int minValue = int.MaxValue;
foreach (int n in a)
{
if(n<minValue) minValue = n;
}
return minValue;
}
int[,] a = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } };
foreach (int item in a)
{
Console.WriteLine(item);
}