/// <summary> /// 初始化 <see cref="Group"/> 类的新实例 /// </summary> /// <param name="id">当前实例指定的 Id</param> /// <param name="name">当前实例指定的群名</param> /// <param name="currentCount">当前实例当前的群人数</param> /// <param name="maxCount">当前实例最大群人数</param> /// <exception cref="ArgumentOutOfRangeException">id 小于 <see cref="MinValue"/></exception> public Group(long id, string name, int currentCount, int maxCount) { if (id < _minValue) { throw new ArgumentOutOfRangeException(nameof(id)); } this.Id = id; this.Name = name; this.CurrentMemberCount = currentCount; this.MaxMemberCount = maxCount; this.MemberCollection = new GroupMemberCollection(); }
/// <summary> /// 指示当前对象是否等于同一类型的另一个对象 /// </summary> /// <param name="obj">一个与此对象进行比较的对象</param> /// <returns>如果当前对象等于 obj 参数,则为 <see langword="true"/>;否则为 <see langword="false"/></returns> public bool Equals(GroupMemberCollection other) { if (other is null) { return(false); } if (this.Count != other.Count) { return(false); } for (int i = 0; i < this.Count; i++) { if (!this[i].Equals(other[i])) { return(false); } } return(true); }