using System; using System.Collections.Generic; namespace Masuit.Tools.DateTimeExt { /// /// 日期信息 /// public readonly record struct DateInfoStruct : IEquatable { /// /// 月 /// public readonly int Month; /// /// 日 /// public readonly int Day; /// /// 假期长度 /// public readonly int Recess; /// /// 节假日名 /// public readonly string HolidayName; /// /// 日期信息 /// /// /// /// /// public DateInfoStruct(int month, int day, int recess, string name) { Month = month; Day = day; Recess = recess; HolidayName = name; } /// 指示当前对象是否等于同一类型的另一个对象。 /// 一个与此对象进行比较的对象。 /// 如果当前对象等于 参数,则为 true;否则为 false。 public bool Equals(DateInfoStruct other) { return Month == other.Month && Day == other.Day && Recess == other.Recess && HolidayName == other.HolidayName; } /// 返回此实例的哈希代码。 /// 一个 32 位带符号整数,它是此实例的哈希代码。 public override int GetHashCode() { unchecked { var hashCode = Month; hashCode = (hashCode * 397) ^ Day; hashCode = (hashCode * 397) ^ Recess; hashCode = (hashCode * 397) ^ (HolidayName != null ? HolidayName.GetHashCode() : 0); return hashCode; } } } }