標籤

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;
       }
}

沒有留言:

智慧型應用程式控制

現象: 解法