System.Collections.ArrayList.LastIndexOf C# (CSharp) Method

LastIndexOf() public method

public LastIndexOf ( Object value ) : int
value Object
return int
        public virtual int LastIndexOf(Object value)
        {
            Contract.Ensures(Contract.Result<int>() < _size);
            return LastIndexOf(value, _size - 1, _size);
        }

Same methods

ArrayList::LastIndexOf ( Object value, int startIndex ) : int
ArrayList::LastIndexOf ( Object value, int startIndex, int count ) : int

Usage Example

Example #1
0
        public void TestLastIndexOfBasic()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ndx = -1;
            //
            //  Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);

            //
            // []  Obtain last index of "Batman" items.
            //
            ndx = arrList.LastIndexOf("Batman");
            if (ndx != -1)
            {
                Assert.Equal(0, strHeroes[ndx].CompareTo((string)arrList[ndx]));
            }

            //
            // []  Attempt to find null object.
            //
            // Remove range of items.
            ndx = arrList.LastIndexOf(null);
            Assert.Equal(-1, ndx);

            // []  Call LastIndexOf on an empty list
            var myList = new ArrayList();
            var lastIndex = myList.LastIndexOf(6);

            Assert.Equal(-1, lastIndex);
        }
All Usage Examples Of System.Collections.ArrayList::LastIndexOf