Search code examples
c#collectionsgeneric-collections

Converting ObservableCollection<T> to ObservableCollection<String>


I have an ObservableCollection<T>. T has a ToString() method. What I'd like to do is convert the ObservableCollection<T> to ObservableCollection<string>. Having done a quick search, I found a few articles that suggested a foreach approach - is there another way? e.g.:

myCollection.ToObservableCollection();

Solution

  • var newCollection = new ObservableCollection<string>(myCollection.Select(x => x.ToString()));