开发者

I got error PlatformNotSupportedException when I work with date's

开发者 https://www.devze.com 2023-04-09 06:06 出处:网络
I work on windows-mobile 6.5 the region is English (United States) date: M/d/yy time: h:mm:ss tt I\'ve this code:

I work on windows-mobile 6.5

the region is English (United States) date: M/d/yy time: h:mm:ss tt

I've this code:

DateTime dt_1,dt_2;
try
    {
         CultureInfo obj = new CultureInfo("en-US");
         dt_1 = DateTime.Parse(TmpD_from, obj);
    }
catch
    {
          CultureInfo obj = new CultureInfo("he-IL");
          dt_1 = DateTime.Parse(TmpD_from, obj);
    }

try
    {
          CultureInfo obj = new CultureInfo("en-US");
          dt_2 = DateTime.Parse(TmpD_to, obj);
    }
catch
    {
          CultureInfo obj = new CultureInfo("he-IL");
          dt_2 = DateTime.Parse(TmpD_to, obj);
    }

if (DateTime.Today >= dt_1.Date && DateTime.Today <= dt_2.Date)
    {
          return true;
    }
else
    {
           return false;
    }

the values:

开发者_StackOverflow社区
TmpD_to:   31/12/2011 00:00:00
TmpD_from: 31/12/2011 00:00:00

and I got this error: PlatformNotSupportedException


You probably get the Exception because the culture "he-IL" (Hebrew, right?) is not supported by Windows Mobile 6.5. I would suggest trying another culture, whose formatting results are close (or equal) to what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消