I have a class with a property IEnumerable. How do I make a generic method that creates a new List and assigns that property?
using System;
using System.Collections.Generic;
namespace ConsoleApplication16
{
class Program
{
static IEnumerable Func()
{
yield return 1;
yield return 2;
yield return 3;
}
static List MakeList()
{
return (List)Activator.CreateInstance(typeof(List), Func());
}
static void Main(string[] args)
{
foreach(int i in MakeList())
{
Console.WriteLine(i);
}
}
}
}