Indexer as part of the interface in C#

人盡茶涼 提交于 2019-12-05 04:51:15
public interface IYourList<T>
    {
        T this[int index] { get; set; }
    }

It is - it's pretty odd syntax at other times if you ask me! But it works. You have to declare the get; and/or set; parts of it with no definition, just a semi-colon, exactly like ordinary properties in an interface.

I know what you mean but, yes, this is correct. Here are the docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!