开发者

C# iterator with string key

开发者 https://www.devze.com 2023-01-23 03:34 出处:网络
I wish t开发者_运维百科o write a class similar to the dictionary class where I can add the text value of an object and return the object.

I wish t开发者_运维百科o write a class similar to the dictionary class where I can add the text value of an object and return the object.

I was wondering if there is a simple way to do this in C# 3.5 without having a dictionary object inside my class (without using the dictionary class).

Thanks in advance,


Do you mean a string indexer?

class Foo
{
    public object this[string key]
    {
        get
        {
            // Get the value.
        }
        set
        {
            // Set the value.
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消