System.Collections.SortedList.GetByIndex C# (CSharp) Method

GetByIndex() public method

public GetByIndex ( int index ) : Object
index int
return Object
        public virtual Object GetByIndex(int index)
        {
            if (index < 0 || index >= Count)
                throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
            Contract.EndContractBlock();
            return _values[index];
        }

Same methods

SortedList::GetByIndex ( int index ) : object

Usage Example

Beispiel #1
0
        private Image GetAny()
        {
            Image  oPic;
            string sname;

            System.Collections.SortedList filelist = new System.Collections.SortedList();
            foreach (string newname in oExt.ArchiveFileNames)
            {
                if (IsImage(newname))
                {
                    filelist.Add(newname, newname);
                }
            }
            sname = Convert.ToString(filelist.GetByIndex(0));
            Random anyimageindex = new Random();

            sname = Convert.ToString(filelist.GetByIndex(anyimageindex.Next(filelist.Count)));
            Stream iStream = new System.IO.MemoryStream();

            try
            {
                oExt.ExtractFile(sname, iStream);
            }
            catch (Exception ex)
            {
                ComicError("Connot extract " + sname + " from " + currentFile);
                ComicError(ex.Message);
                return(null);
            }
            oPic = System.Drawing.Bitmap.FromStream(iStream);
            return(oPic);
        }
All Usage Examples Of System.Collections.SortedList::GetByIndex