1
Reply

Dicionary<String, List<ColorObject>> Linq Contains and Sort

David Smith

David Smith

Jul 30 2016 10:03 AM
270

I have a dictionary collection managing a list of ColorObjects. The color list object is updated every 2 seconds.

1. How to check if the list of ColorObject in the ColorDictionary contains colorName and if ObjectHandle is not null using linq or lambda? Review below

The ColorObject I am managing

public class ColorObject

{

public int colorId { get; set; }

public string colorName { get; set; }

public ObjectHandle { get; set; }

}

Dicionary<String, List<ColorObject>> ColorDictionary = new Dicionary<String, List<ColorObject>>();

if(!ColorDictionary.ContainKey(colorKey))

{

1. How to check if the list of ColorObject in the ColorDictionary contains colorName and if ObjectHandle is not null using linq or lambda and then save it back to the dictonary?

2. Then after saving back to the dictionary, I want to sort each list by index.

}


Answers (1)