疑惑解答1

            int a;
            float b;
            //a = null;
            //b = null;
            //if (a == null || b == null)
            //{
            //    //int a和float b必须赋值,并且a不能为null
            //    Console.WriteLine("a or b is null");
            //也就是数字必须有非null的值
            //}
            string str;
            //方法里的变量必须赋值;
            str = null;
            if (string.IsNullOrEmpty(str))
            {
                Console.WriteLine("string is null or empty");
            }

            MItem mItem = null;
            if (mItem == null)
            {
                Console.WriteLine("class could be null");
            }

            mItem = new MItem();
            if (mItem != null)
            {
                Console.WriteLine("赋过值的class不会为null");
            }
            Console.WriteLine(mItem.ck);//默认False
            Console.WriteLine(mItem.dt.ToString("yyyy-MM-dd"));//默认0001-01-01;
            Console.WriteLine(mItem.val);//decimcal默认0
            Console.WriteLine(mItem.value);//int默认0




          public class MItem
          {
            public string id { set; get; }
            public DateTime dt { set; get; }
            public decimal val { set; get; }
            public int value { set; get; }
            public string Rank { set; get; }
            public List<string> idList { set; get; }


            public bool ck { set; get; }
          }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值