Converting an array to an ObservableCollection

Robert Strauch picture Robert Strauch · Mar 8, 2013 · Viewed 12.2k times · Source

In a C# application the following array is used:

CProject[] projectArray = this.proxy.getProjectList(username, password);

However I need the projectArray as a ObservableCollection<CProject>. What would be the recommended way to do this? So far I'm using the following statement:

ObservableCollection<CProject> projectList = new ObservableCollection<CProject>(projectArray);

Would you also use this statement or would you recommend other ways?

Answer

ken2k picture ken2k · Mar 8, 2013

Building a new collection from an IEnumerable as you did is the way to do it.