索引器作为C#中接口的一部分 [英] Indexer as part of the interface in C#

查看:89
本文介绍了索引器作为C#中接口的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,将索引器声明为接口的一部分的语法是什么?它还是这个[] 吗?在界面中使用 this 关键字会有些奇怪。

In C#, what's the syntax for declaring an indexer as part of an interface? Is it still this[ ]? Something feels odd about using the this keyword in an interface.

推荐答案

public interface IYourList<T>
    {
        T this[int index] { get; set; }
    }

这篇关于索引器作为C#中接口的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆