DataTime? 的 GetValueOrDefault() 方法

DataTime? 转换为 DataTime类型 就可以调用 ToString()  自定义格式

@item.CreateDate.GetValueOrDefault().ToString("yyyy-MM-dd");

 

// 摘要:
// 获取一个值,指示当前的 System.Nullable<T> 对象是否有值。
//
// 返回结果:
// 如果当前的 System.Nullable<T> 对象具有值,则为 true;如果当前的 System.Nullable<T> 对象没有值,则为
// false。
public bool HasValue { get; }

 

//
// 摘要:
// 检索当前 System.Nullable<T> 对象的值,或该对象的默认值。
//
// 返回结果:
// 如果 System.Nullable<T>.HasValue 属性为 true,则为 System.Nullable<T>.Value 属性的值;否则为当前
// System.Nullable<T> 对象的默认值。默认值的类型为当前 System.Nullable<T> 对象的类型参数,而默认值的值中只包含二进制零。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public T GetValueOrDefault();

转载于:https://www.cnblogs.com/cjm123/p/7943918.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值