Hello All,
I have a collection of graphics, I've added an attribute called "Id" for each graphic.
What would be the best way to find a graphic by its Id?
Do I have to iterate all the collection?
Please advice
Best Regards
Hi,
You can use Linq to query the Graphics collection for Graphics with attribute ["Id"] which match the specified value.
Cheers
Mike
Something like this should work ....
var graphics = new GraphicCollection();
graphics = // your code here
int interestingId = 1;
var interestingGraphic = graphics.FirstOrDefault( g => (int) g.Attributes["Id"] == interestingId);