How to Convert a List to ObservableCollection in C#?


This content was proof-read by Grammarly. You can Try Grammary for FREE

This simple blog post will explain how to convert a List of Object to ObservableCollection of Object in C# and Windows Phone 8.

There are times when you want to convert a List of Object to ObservableCollection specially when binding an ObservableCollection to the LongListSelector etc. The reasons for this can be several.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book BUY & DOWNLOAD GRAPHQL.NET COOKBOOK

How to Convert a List to ObservableCollection in C#?

To Convert a List to ObservableCollection in C#, Follow the below steps

Assume that you have List<Employee> which needs to be converted to ObservableCollection<Employee>. Below is a sample code snippet that does this.

List<Employee> employees = new List<Employee>();

ObservableCollection<Employee> sessions = new ObservableCollection<Employee>(employees);
%d bloggers like this: