an I prevent a specific type using generic restrictions

后端 未结 4 609
悲&欢浪女
悲&欢浪女 2021-01-18 13:03

I have an overload method - the first implementation always returns a single object, the second implementation always returns an enumeration.

I\'d like to make the m

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-18 13:52

    Rename one of the methods. You'll notice that List has an Add and and AddRange method; follow that pattern. Doing something to an item and doing something to a sequence of items are logically different tasks, so make the methods have different names.

提交回复
热议问题