c# - Update existing value in an ObservableCollection -



c# - Update existing value in an ObservableCollection -

i'm trying update & add together values observablecollection

i have defined observablecollection this;

public observablecollection<tuple<string, int>> logsummary { get; set; }

in class i'm subscribing event sends string containing letter: a,b,c,d,e or f.

if string received exists in collection want update sec item(int) count of string letter receive.

if write code

logsummary.add(new tuple<string, int>(_stringfromevent, intvalue));

this add together new row in collection before utilize logsummary.add() need figure out how check if string exists , if should take current int value , update instead of adding new row collection.

hope understand problem! in advance, jack

var existing = logsummary.firstordefault(t=>t.item1 == _stringfromevent) if(existing != null) { //update logsummary[logsummary.indexof(existing)] = new tuple<string, int>(existing.item1, intvalue); } else { //insert new }

c# .net xaml c#-4.0

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -