Why are parameter names necessary in an interface definition? I am allowed to choose new parameter names during implementation

后端 未结 6 1825
粉色の甜心
粉色の甜心 2020-12-11 00:16

Not sure if this is a silly question, but I just noticed this:

public interface IActivityDao : IDao
{
    IList GetAllSinceSe         


        
6条回答
  •  粉色の甜心
    2020-12-11 01:20

    I would imagine this is due to the named parameters feature in C#. Ie, you need to be able to specify parameters by name, not just in the default order:

    IActivityDao dao;
    dao.GetAllSinceSequence(count: 1, sequence: 2);
    

    Of course, the parameter names would be different if the object is cast as your instance.

    var concreteDao = (ActivityDao) dao;
    concreteDao.GetAllSinceSequence(maxRecords: 1, sequence: 2);
    

提交回复
热议问题