標籤

2024年7月3日 星期三

C#各類判斷式

線上測試:learn.microsoft.com

www.w3schools.com

isDate 

public static bool IsDate(Object obj)

{
        string strDate = obj.ToString();
        try
        {
            DateTime dt = DateTime.Parse(strDate);
            if((dt.Month!=System.DateTime.Now.Month) || (dt.Day<1&&dt.Day>31) || dt.Year!=System.DateTime.Now.Year)
                return false;
            else
                return true;
       }
       catch
       {
            return false;
       }
}

沒有留言:

WIN32_WMISetting命名空間無效,導致.NET System.Management.ManagementException

問題 ReadyGo在LOGIN,判定CPUID時,因無Windows Management Instrumentation的類別,造成 System.Management.ManagementException: Invalid namespace 原因:此錯誤是由 WMI 問...