My sample code:
using System.Collections.Generic;
using System.Collections.ObjectModel;
class Program
{
static void Main(string[] args)
{
ObservableCollection< Employee> obc = new ObservableCollection< Employee>(GetEployeeList());
}
public static IEnumerable< Employee> GetEployeeList()
{
for (int i = 0; i < 5; i++)
{
yield return new Employee { ENumber = i + 1, EName = "Name" + (i + 1).ToString() };
}
}
}
public class Employee
{
public int ENumber { get; set; }
public string EName { get; set; }
}
No comments:
Post a Comment