none
C# listbox array "Index was outside the bounds of the array" RRS feed

  • Question

  • Error : "Index was outside the bounds of the array"

     VideoSearch items = new VideoSearch();
                List<Video> list = new List<Video>();
                ListBox[] listbox = new ListBox[richTextBoxSearch.Lines.Length-1];
    
                for (int i = 0; i <= richTextBoxSearch.Lines.Length-1; i++)
                {
    
                    string richlines = richTextBoxSearch.Lines[i];
    
    
                  
    
                    listbox[i] = new ListBox();
    
                    foreach (var item in items.SearchQuery(richlines, 1))
                    {
    
                        Video video = new Video();
                        video.Url = item.Url;
                        list.Add(video);
                        //List<ListBox> listboxes;
                        //listboxes = new List<ListBox> { listBox1, listBox2 };
    
                         
                       listbox[i].Items.Add(video.Url);
                    }
    
                }

    What is the problem here ? Could you help me , please ?


    Tuesday, March 27, 2018 8:41 PM

Answers