Cast Object to Generic List

后端 未结 8 1314
野趣味
野趣味 2020-12-03 03:37

I have 3 generict type list.

List = new List();
List
= new List
(); List = new Lis
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 04:24

    No, you can't cast without going around corners (this is: reflection), generic type parameters have to be known at compile time. You can of course do something like this:

    content.Where(o => o is type).ToList().Foreach(stuff);

提交回复
热议问题