I got error PlatformNotSupportedException when I work with date's

家住魔仙堡 提交于 2019-12-13 00:22:23

问题


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:

TmpD_to:   31/12/2011 00:00:00
TmpD_from: 31/12/2011 00:00:00

and I got this error: PlatformNotSupportedException


回答1:


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.



来源:https://stackoverflow.com/questions/7606810/i-got-error-platformnotsupportedexception-when-i-work-with-dates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!