In C#, What is After a Method Declaration?

前端 未结 4 1861
有刺的猬
有刺的猬 2020-12-09 15:58

I\'m a VB.Net guy. (because I have to be, because the person who signs my check says so. :P) I grew up in Java and I don\'t generally struggle to read or write in C# when

4条回答
  •  伪装坚强ぢ
    2020-12-09 16:13

    This defines a generic method, which is one form of generics, which were added to C# in C# 2.0.

    The method sig should be:

    static void Foo(params T[] x)
    { // ...
    

    This lets you pass any number of arguments of any (specific) type into the method Foo, and it acts on that array of arguments. It's similar to how generic types work, except scoped just to the method. The specifies the type of the argument being passed into the method, so you can call this like:

    Foo(myClassInstance, myClassInstance2, mySubclassInstance);
    

提交回复
热议问题