简体   繁体   English

模板变量和可以存储模板变量的变量

[英]Template variables and the variables that can store template variables

There is two variables 有两个变量

 basic<type1> type_1;
 basic<type2> type_2;

I want to this two variables to store another variable like this 我想要这两个变量来存储另一个这样的变量

basic<type1> type_1;
basic<type2> type_2;

var type = type_1 or type_2 // What type of variable should be declared?

Thank you. 谢谢。

You can use object or dynamic . 您可以使用objectdynamic

Also, if basic<T> inherits from let say basic you will be able to use basic as the variable type. 另外,如果basic<T>继承自可以说basic那么您将可以使用basic作为变量类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM