Search code examples
c#windows-phone-8

How to convert List to observablecollection


Hi all I have a Json class as shown below:

private class RootObject
{
    public string flag { get; set; }
    public string message { get; set; }
    public Result result { get; set; }
}

public class Result
{
    public List<List<string>> professions { get; set; }
}

How can I convert the result class into an observable collection?


Solution

  • ObservableCollection<T> have constructor which takes IEnumerable<T>

    ObservableCollection<string> myCollection = new ObservableCollection<string>(Result);