In C#, What is After a Method Declaration?

前端 未结 4 1860
有刺的猬
有刺的猬 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

    The T is a type parameter and in this case can be anything (a constraint may be specified, but here there is no constraint). Without this feature you would have to declare the method for every type you plan to use:

    static void Foo(params int[] x)    
    static void Foo(params string[] x)    
    static void Foo(params Customer[] x)    
    etc...
    

    More information on generics can be found on MSDN: Introduction to Generics (C#).

提交回复
热议问题