【问题标题】:Is it possbile to implement the index operator '[]' with generic capability [duplicate]是否可以使用通用功能实现索引运算符“[]”[重复]
【发布时间】:2013-02-04 08:27:37
【问题描述】:

可能重复:
Why it is not posible to define generic indexers in .NET?
how to write a function to take any object with an index operator

我从未见过这样的用法。但我只是想知道是否有可能做出像 bleow 这样的实现。我知道它不起作用。但我的意思是如果存在类似的用法。

public T this<T>[T param]
{
    get 
    {
        ....
    }
}

【问题讨论】:

标签: c# generics indexing brackets


【解决方案1】:

不,通用属性和索引器(a 属性)是不可能的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-28
    • 2022-01-12
    • 2012-12-27
    • 2021-07-22
    • 2017-02-01
    • 2013-02-11
    相关资源
    最近更新 更多