List GetRange error in C#

前端 未结 3 1249
再見小時候
再見小時候 2021-01-19 04:56

i am working with list and my list has 14 record.

 List oProduct = new List 
        {
           new Product(\"../images/1.jpg         


        
相关标签:
3条回答
  • 2021-01-19 05:27

    The second parameter to GetRange needs to be the count of elements to get, so change it to 4 (I think that's what you want).

    Also, the first parameter is the zero-based index, so you want GetRange(9, 4) to get images 10 through 13.

    0 讨论(0)
  • 2021-01-19 05:27

    List<T>.GetRange takes start and count, not start and end. If you want elements 10-13, use GetRange(10, 4).

    0 讨论(0)
  • 2021-01-19 05:30

    You are asking for 13 elements, starting from element ten.

    0 讨论(0)
提交回复
热议问题