Cannot convert from List to List

后端 未结 3 1902
我在风中等你
我在风中等你 2021-02-01 13:33

I have a set up like this:

abstract class Foo {}
class Bar : Foo {}

and a method elsewhere of this form:

void AddEntries(List&l         


        
3条回答
  •  滥情空心
    2021-02-01 14:26

    You could make your AddEntries generic and change it to this

    void AddEntries(List test) where T : Foo
    {
        //your logic 
    }
    

    Have a look at Constraints on Type Parameters for further information.

提交回复
热议问题