使用 AddRange 方法将多个 ListItem 对象添加到集合

ListItemCollection myListItemCollection = new ListItemCollection();

// Creates an array of ListItems that are used to populate the collection.    
System.Web.UI.WebControls.ListItem[] newListItemArray = new ListItem[tempDataTable.Count];

// Populates the array of ListItems with generic data.
for (int i=0; i < tempDataTable.Count; i++) {
    newListItemArray[i] = new ListItem();
    newListItemArray[i].Text = "Item " + i.ToString();
    newListItemArray[i].Value = i.ToString();
}

// Adds an entire array of ListItem objects to the collection.
myListItemCollection.AddRange(newListItemArray);
原文地址:https://www.cnblogs.com/jianfangkk/p/1367188.html