在过去的日期没有选择日期和期限日期是在C#中使用customva选择的 [英] Not selted in past date curent date and futcher date is select in C# using in customva

查看:106
本文介绍了在过去的日期没有选择日期和期限日期是在C#中使用customva选择的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你

过去的日期在erroe中没有被列出

todey date和fycher date被选中

在c#中使用customvelitoan



我尝试过:



//尝试

// {

// DateTime.ParseExact(args.Value,m / d / yyyy,

// System.Globalization.DateTimeFormatInfo.InvariantInfo) ;

// args.IsValid = true;

//}

// catch

// {

// args.IsValid = false;

//}

i need you
past date is not selevted in erroe
todey date and fycher date is selected
in c# using customvelitoan

What I have tried:

// try
//{
// DateTime.ParseExact(args.Value, "m/d/yyyy",
// System.Globalization.DateTimeFormatInfo.InvariantInfo);
// args.IsValid = true;
//}
//catch
//{
// args.IsValid = false;
//}

推荐答案

首先,停止使用异常作为正常处理的一部分 - 改为使用TryParseExact:

First off, stop using exceptions as part of your normal processing - use TryParseExact instead:
DateTime dt;
args.IsValid = DateTime.TryParseExact(args.Value, "M/d/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt);

其次,请注意日期格式的情况:M是月,m是分钟......

And second, note the case on the date format: "M" is month, "m" is minute ...


这篇关于在过去的日期没有选择日期和期限日期是在C#中使用customva选择的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆