c# - StringCollection vs. ObservableCollection<string> -
i trying grasp concepts of collections in c#. working on app based on wpf , mvvm. want viewmodel have sort of list or collection of strings, can create utilize of "onchangedeventhandler", such notifycollectionchangedeventhandler. provided observablecollection class. in contrast observablecollection class, stringcollection class prvides contains method determine whether specified string in collection.
what should utilize if want have both "contains method" , "onchangedeventhandler"?
update
solved by:
public class mystringcollection : observablecollection<string> { private observablecollection<string> strings = new observablecollection<string>(); // check if mystringcollection contains specified string public bool contains(string str) { homecoming (strings.any(c => (string.compare(str, c) == 0))); } }
observablecollection supports conatins method extension.
just add together next using statement class:
using system.linq; c# string collections
No comments:
Post a Comment