开发者

Using get[int index] and set[int index] to update values in an array

开发者 https://www.devze.com 2023-03-04 05:48 出处:网络
I am trying to provide a way to update a value inside an array in vala, for example myClass.Channels[10]=15, however, I can\'t find a way to do this in vala. The following works in C#, and I would hav

I am trying to provide a way to update a value inside an array in vala, for example myClass.Channels[10]=15, however, I can't find a way to do this in vala. The following works in C#, and I would have assumed that vala was similar.

private int[] _channels;

public int[] Channels
{
    get[int index]
    {
        return _channels[index];
    }
    set[int index]
    {
        _channels[index] = v开发者_StackOverflow社区alue;
    }
}

Does anybody know if a way of doing this exists?


Vala supports Indexers, see http://live.gnome.org/Vala/ValaForCSharpProgrammers#Indexers

It can only be used on class, not on arrays.

If that's really useful for you, you should open a bug (and even provide a patch!)

0

精彩评论

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