Adding an IList item to a particular index number

Posted by Dr. Zim on Stack Overflow See other posts from Stack Overflow or by Dr. Zim
Published on 2010-06-01T04:23:24Z Indexed on 2010/06/01 4:33 UTC
Read the original article Hit count: 318

Filed under:
|

Our Client's database returns a set of prices in an array, but they sometimes don't include all prices, i.e., they have missing elements in their array. We return what we find as an IList, which works great when we retrieve content from the database. However, we are having difficulties setting the elements in the proper position in the array.

Is it possible to create an IList then add an element at a particular position in the IList?

var myList = new List<Model>();
var myModel = new Model();
myList[3] = myModel;  // Something like what we would want to do

© Stack Overflow or respective owner

Related posts about c#

Related posts about ilist