- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Max_Min语句
- {
- class Program
- {
- static void Main(string[] args)
- {
- int i;
- short s;
- float f;
- decimal d;
- i = int.MaxValue; //赋32位整数类型变量最大值
- Console.WriteLine("int MaxValue is {0}", i);
- i = int.MinValue; //赋32位整数类型变量最小值
- Console.WriteLine("int MinValue is {0}", i);
- s = short.MaxValue; //赋16位整数类型变量最大值
- Console.WriteLine("short MaxValue is {0}", s);
- s = short.MinValue; //赋16位整数类型变量最小值
- Console.WriteLine("short MinValue is {0}", s);
- f = float.MaxValue; //赋单精度类型变量最大值
- Console.WriteLine("float MaxValue is {0}", f);
- f = float.MinValue; //赋单精度类型变量最小值
- Console.WriteLine("float MinValue is {0}", f);
- d = decimal.MaxValue; //赋小数类型变量最大值
- Console.WriteLine("decimal MaxValue is {0}", d);
- d = decimal.MinValue; //赋小数类型变量最小值
- Console.WriteLine("decimal MinValue is {0}", d);
- Console.ReadKey();
- }
- }
- }
复制代码
C#中利用MaxValueMinValue取最大值和最小值。如取int类型的最大值和最小值就可以利用int.MaxValue和int.MinValue来取其最大值和最小值。
|