Main.cs

注: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.
网友评论