Having a checkedboxlist databound with encrypted listitem value, i had written a method to return a array holding respective checked items on postback. Signature of which would be similar to below
private Array GetCheckedItems(CheckBoxList ctrlChkbox)
{
//decrypt and push to array
}
Is this a optimal object to return. I will be accessing the array items again to be individually pushed into DataBase.( I will also be binding the same data with a gridview again to show the records. It's like single page form with a gridview to show records) Which objects might get me benefits and performance than arrays. key based would be nice i feel. Advice me on this please, Regards, Deeptechtons
Performance around collections is quite difficult to answer.
Array
"simple" provides good performances if items count is known (like it seems for you, if the checked item list is accessible from UI), and if you access it quite straight-forwardly.
Little informations about List<T>
, as you said you would put it back into a gridview.
You should try to be concerned (depending on element's number, always) about "boxing/unboxing" informations.
I think that would be your main issue.
Extracting value to push it into database or to gridview may be two different uses for your datas.
if "boxing/unboxing" match your concern more than collecting elements, a linkedList could be a way to insert/read it one after the other.
In case of many elements (don't know which number), addRange()
in List<T>
is also to consider
Always many ways to do it, hard to
精彩评论