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);
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.