Using List in C# (Generics)

前端 未结 4 419
灰色年华
灰色年华 2021-02-03 22:25

That\'s a pretty elementary question, but I have never delved into generics before and I found myself in the need to use it. Unfortunately I don\'t have the time right now to go

4条回答
  •  有刺的猬
    2021-02-03 22:32

    You need to add the generic type parameter for T to your method:

    void MyMethod(List list) {
    

    The compiler doesn't know what T represents, otherwise.

提交回复
热议问题