using System;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int max = int.MinValue, min = int.MaxValue;
int value;
Console.WriteLine("请输入3个整数");
for (int i = 0; i < 3; i++)
{
Console.Write("第{0}个数:", i + 1);
string s = Console.ReadLine();
if (!int.TryParse(s, out value))
{
Console.WriteLine("请输入一个整数!");
i--;
}
else
{
if (value > max) max = value;
if (value < min) min = value;
}
}
Console.WriteLine("最大值:{0}; 最小值:{1}", max, min);
Console.ReadLine();
}
}
}
百度一下排序方法,取出排序后的第一个值就是你要的结果!
List
3 infoList.Add(
4 new Info() { Id = 1, Name = "woft" });
5 infoList.Add(new Info() { Id=3,Name="rose"});
6 infoList.Add(new Info() { Id = 2, Name = "abc" });
7 Console.WriteLine("ReadT*********************");
8 IEnumerable
9 query = from items in infoList orderby items.Id select items;
10 foreach (var item in query)
11 {
12 Console.WriteLine(item.Id+":"+item.Name);
13 }