我不希望我的列表是固定类型的。相反,我希望列表的创建取决于变量的类型。以下代码不起作用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string something = "Apple";
Type type = something.GetType();
List<type> list = null;
Console.ReadKey();
}
}
}
有人能告诉我需要做哪些修改才能让它正常工作吗?我希望list
的创建取决于something
变量的类型。