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);
                            }

  • 相关阅读:
    JS权威指南读书笔记(二)
    JS权威指南读书笔记(一)
    NodeList和HTMLCollection区别
    2016年前端技术展望
    Label标签for属性
    JavaScript Array vs new Array区别
    禁止滚动事件方法
    shim和polyfill 区别解释
    Html5知识精粹纪录
    前端url 相关设置获取总结
  • 原文地址:https://www.cnblogs.com/YangBinChina/p/2703641.html
Copyright © 2011-2022 走看看