How do i remove a specific collection from my model in C# -
this model:
public class obsmodel : bindablebase { private string _obsname = string.empty; public string obsname { { return this._obsname; } set { this.setproperty(ref this._obsname, value); } } private string _obscolor = string.empty; public string obscolor { { return this._obscolor; } set { this.setproperty(ref this._obscolor, value); } } private string _obsvalue = string.empty; public string obsvalue { { return this._obsvalue; } set { this.setproperty(ref this._obsvalue, value); } } }
i can populate model using object.
observablecollection<obsmodel> lastobsresults = new observablecollection<obsmodel>();
but how can remove particular collection if have example observation name string variable using code below?
latsobsresults.remove( put here);
you remove object collection passing in object remove. can done through linq so:
lastobsresults.remove(lastobsresults.firstordefault(obs => obs.obsname == name));
Comments
Post a Comment