예제 #1
0
        public void AddItem_Fact()
        {
            var list = new StringList();

            list.ShouldHaveState(0, 0);
            list.Add("Hello");
            list.ShouldHaveState(1, 1, "Hello");
            list.Add("Good-bye");
            list.ShouldHaveState(2, 2, "Hello", "Good-bye");
        }
예제 #2
0
        public StringList CloneSublist(int count)
        {
            if (count < 0 || count > _storage.Count)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (count == Count)
            {
                return(new StringList(this));
            }
            var clone      = new StringList();
            var enumerator = new StringListEnumerator(_storage, false);

            while (count > 0)
            {
                enumerator.MoveNext();
                clone.Add(enumerator.Current);
                count--;
            }
            return(clone);
        }