Chr*_*ris 82 c# generics types instance
是否可以实现以下代码?我知道它不起作用,但我想知道是否有解决方法?
Type k = typeof(double);
List<k> lst = new List<k>();
Run Code Online (Sandbox Code Playgroud)
Dav*_*d M 116
就在这里:
var genericListType = typeof(List<>);
var specificListType = genericListType.MakeGenericType(typeof(double));
var list = Activator.CreateInstance(specificListType);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
44269 次 |
最近记录: |