コード例:
void Foo(params object[] objects)
{
var entries = new List<IEntry>();
foreach(var o in objects)
{
var entry = new Entry<o.GetType()>(); // this doesn't work
entries.Add(entry);
}
...
}
Foo("hello", 5); // should fill entries with Entry<string> and Entry<int>
なぜそれが不可能なのですか?代わりにリフレクションを使用する必要があると思いますか?それを適切かつパフォーマンス的に行う方法は?