日期的数据注释范围 [英] Data Annotation Ranges of Dates
本文介绍了日期的数据注释范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以对日期使用 [Range]
注释?
Is it possible to use [Range]
annotation for dates?
类似的东西
[Range(typeof(DateTime), DateTime.MinValue.ToString(), DateTime.Today.ToString())]
推荐答案
MSDN 上的文档 说你可以使用 RangeAttribute
Docs on MSDN says you can use the RangeAttribute
[Range(typeof(DateTime), "1/2/2004", "3/4/2004",
ErrorMessage = "Value for {0} must be between {1} and {2}")]
public datetime Something { get; set;}
这篇关于日期的数据注释范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文