Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 模板变量和可存储模板变量的变量_C#_Templates_Types - Fatal编程技术网

C# 模板变量和可存储模板变量的变量

C# 模板变量和可存储模板变量的变量,c#,templates,types,C#,Templates,Types,有两个变量 basic<type1> type_1; basic<type2> type_2; 我想用这两个变量来存储另一个这样的变量 basic<type1> type_1; basic<type2> type_2; var type = type_1 or type_2 // What type of variable should be declared? 谢谢。您可以使用对象或动态 另外,如果basic继承自basic,您将能够使

有两个变量

 basic<type1> type_1;
 basic<type2> type_2;
我想用这两个变量来存储另一个这样的变量

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

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

您可以使用对象或动态


另外,如果basic继承自basic,您将能够使用basic作为变量类型。

您能否澄清您的问题?正确,但不完整。。。实际上,任何基类都可以,例如对于basic:root1:root2:root3,除了对象之外,您还可以使用所有rootX