惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
博客园_首页
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
D
Docker
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
小众软件
小众软件
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky

博客园 - 空军

过多边形边上某点的任意直线等分面积 VisualAPL Installer for Visual Studio 2008 [ZT] Create a Microsoft Access Database Using ADOX and Visual Basic .NET 数的分解,据说是清华的一道复试上机题 为System.Windows.Forms.FontDialog类添加Location属性 f(f(x)) = -x [zt]〖Math〗构造函数使得任意小的区间所对应的值域都是整个实数域 [zt]鸟巢、水立方:同一个地方,同一梦想 〖Math〗据传,任意锐角等于0° 爱因斯坦的超级问题(谁养鱼)SQL解法 “槑囧圐圙”您认得这些汉字吗? 根据URL提取页面的Title,根据网页的charset自动判断Encoding MSDN“MidpointRounding 枚举”中文翻译有误 表达式计算器 Google速记 Google中国编程挑战赛第一轮 Google中国编程挑战赛资格赛 数学家 数据库访问模块
C# 2.0 新特性(泛型、可空类型)应用一例
空军 · 2008-01-29 · via 博客园 - 空军

 1using System;
 2
 3class Test
 4{
 5  static void Main()
 6  {
 7    Console.WriteLine(Max(1));                               // 输出: 1
 8    Console.WriteLine(Max(.3-.5));                         // 输出: 0.3
 9    Console.WriteLine(Max(0M, -3M, 3.14M));                  // 输出: 3.14
10    Console.WriteLine(Max(9f, -1f, 3.14f-2.718f));         // 输出: 9
11    Console.WriteLine(Max(0u23u3114u120718u5678u));  // 输出: 120718
12  }

13
14  static T? Max<T>(params T[] x)
15  where T: struct, IComparable
16  {
17    if (x.Length == 0return null;
18    T a = x[0];
19    foreach (T i in x)
20      if (a.CompareTo(i) < 0) a = i;
21    return a;
22  }

23}

24