有没有办法使用用户的文化来本地化日期范围验证器?我正在寻找一种验证日期并避免提供固定格式的好方法(例如:使用正则表达式验证器执行 dd/mm/yyyy)
最佳答案
使用Date.TryParseExact()
方法,引用documentation .
使用返回的 My.Application.Culture.CurrentCulture.DateTimeFormat
对象的成员,该对象属于 System.Globalization 类。 DateTimeFormatInfo , 以检索当前文化的日期格式(每种文化都有多种格式,例如长格式和短格式...)。
关于c# - 本地化日期验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2448548/