I have an Object array of my class (Item) like below,
class Item
{
int id;
int value;
bool isSelected;
}
Item itemArr[] = new Item [MAXCOUNT];
To retrieve the selected Item ids and store into list, I am using below code
List<int> listOfItems = new List<int>();
listOfItems.AddRange(itemArr.Where(p => (p.IsSelected)
.Select(p => p.ID)).ToArray());
I have one more Dictionary which indicates item id as key and item value as value,
Dictionary<int,int> itemidValueMap = new Dictionary<int,int>();
How to get item id and value pair and store it into this dictionary?
This question is not duplicate. I need to select only the elements which satisfies the condition and store only them in dictionary. But previous question says about adding all the elements into dictionary.