/// <summary> /// removes the element at the beginning of the collection /// </summary> /// <returns></returns> public int RemoveFirst() { if (this.first == null) { throw new Exception(); } else if (this.first == this.last) { var element = this.first.Value; this.first = null; this.last = null; return(element); } else { var element = this.first.Value; this.first = this.first.Next; this.first.Previous = null; return(element); } }