c# - check a condition inside foreach and assign one of the list -
i trying create image editor , using imagelistview dll displaying selected image, , have problem, in situation need value 1 list , situation value list.
i trying below
foreach (imagelistviewitem item in ((flag == 1) ? imagelistview1.items : imagelistview1.selecteditems)) { item.beginedit(); using (image img = image.fromfile(item.filename)) { glb_namelist_arr.add(item.filename); bitmap im=new bitmap(item.filename); glb_image_list_arr.add(im); } item.update(); item.endedit(); }
in line got error :
((flag == 1) ? imagelistview1.items : imagelistview1.selecteditems)
in javascript can use eval()
method here can do?
i'm assuming cannot implicitly convert from... error. yes typically implemented different collection types. source code says imagelistviewselecteditemcollection , imagelistviewitemcollection implements ilist<imagelistviewitem>
.
so, do
var items = ((flag == 1) ? (ilist<imagelistviewitem>)imagelistview1.items : (ilist<imagelistviewitem>)imagelistview1.selecteditems); foreach (imagelistviewitem item in items) { ... }
if not, provide more information problem. error, types of imagelistview1.items
, imagelistview1.selecteditems
, documentation/project link of imagelistview
.
Comments
Post a Comment