Generic Methods Specialization ~

2019-02-12  本文已影响0人  津涵

Main.cs


4.png

注:From the output on the console you can see that the generic Foo method was selected by the Bar method and not the overload with the int parameter. That’s because the compiler selects the method that is invoked by the Bar method during compile time. Because the Bar method defines a generic parameter, and because there’s a Foo method that matches this type, the generic Foo method is called. This is not changed during runtime when an int value is passed to the Bar method.

上一篇 下一篇

猜你喜欢

热点阅读