zoukankan      html  css  js  c++  java
  • C# Datetime 赋空

    如果我们想把一个实例是Datetime的属性,设定为空。

    ① 把这个Datetime的属性的数据类型设定为 Nullable<DateTime> ,

        简写格式是DateTime?  最好用Nullable<DateTime>这种形式。

    ② 使用的时候先判断一下是否有值是否为null,若没有值或者为null,

    我们可以吧值设定为null.

    以下是一个实例:

        public class ReturnInfoModel
        {

          private Nullable<DateTime> _ope_date;

            /// <summary>
            /// 操作日期
            /// </summary>
            public Nullable<DateTime> ope_date
            {
                set { _ope_date = value; }
                get { return (Nullable<DateTime>)_ope_date; }
            }

        }

    使用                        //退换货日期
                            string strReceiveTime = returnInfo.ReceiveTime;
                            if (String.IsNullOrEmpty(strReceiveTime))
                            {
                                returnInfoModel.chaorret_date = null;
                            }
                            else
                            {
                                returnInfoModel.chaorret_date = DateTime.Parse(strReceiveTime);
                            }

  • 相关阅读:
    #一点杂记
    《洛谷P3373 【模板】线段树 2》
    《Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020
    《牛客练习赛72C》
    《hdu2819》
    《hdu2818》
    《Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad)》
    《51nod1237 最大公约数之和 V3》
    对输入的单词进行排序
    快速排序
  • 原文地址:https://www.cnblogs.com/YangBinChina/p/2703641.html
Copyright © 2011-2022 走看看