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);
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.