解决方法
所以我试过了,只是为了确定.事实证明这个工作很好:
void F(int x) { } int G<T,U>(int x) { return x; } class A { } class B { } void Main() { F(G<A,B>(4)); }
但是这会产生一些编译错误:
void F(bool x,bool y) { } void Main() { int G = 0,A = 1,B = 2; F(G<A,B>(4)); }
The type or namespace name ‘A’ could not be found (press F4 to add a using directive or assembly reference)
The type or namespace name ‘B’ could not be found (are you missing a using directive or an assembly reference?)
The variable ‘G’ is not a generic method. If you intended an expression list,use parentheses around the < expression.
所以答案是表达式F(G 函数调用.有许多方法强制编译器将其视为两个参数的单个函数调用:f(g (4))或F(G> A,B>(4)),仅举几个例子.