SoFunction
Updated on 2025-03-07

C# simple method code to determine whether it is a leap year


/// <summary>
///Judge whether it is a leap year?
        /// </summary>
        /// <param name="a_year"></param>
        /// <returns></returns>
        public static bool IsLeapYear(int a_year)
        {
            String s;
            DateTime dt;
            try
            {
                s = (a_year.ToString() + "-02-29");
                dt = (s);
                return true;
            }
            catch
            {
                return false;
            }
        }