原文发布时间为:2008-12-06 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
using System.Collections.Generic;
using System.Text;

namespace fanxing1
{
    class Class2
    {
        static void Main()
        {
            int? num;//System.Nullable<int> num;
            num = null;
            if (num.HasValue)
                Console.WriteLine(num.Value);
            else
                Console.WriteLine("null");

            num = 4;
            int y = num.GetValueOrDefault();
            try
            {
                y = num.Value;
                Console.WriteLine(y);
            }
            catch (System.InvalidOperationException e)
            {
                Console.WriteLine(e.Message);
            }
            num = null;
            int t = num ?? -1;
            Console.WriteLine(t);
            int? i = 5;
            Type tt = i.GetType();
            Console.WriteLine(tt.FullName); //"System.Int32"
             Console.WriteLine(typeof(float?));
            Console.ReadLine();
        }
    }
}

相关文章:

  • 2021-08-27
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-12-15
  • 2021-12-08
  • 2021-10-14
相关资源
相似解决方案