gpt4 book ai didi

c# - 命名索引器属性可能吗?

转载 作者:太空狗 更新时间:2023-10-29 22:15:05 24 4
gpt4 key购买 nike

<分区>

假设我在类中有一个数组或任何其他集合,以及一个返回它的属性,如下所示:

public class Foo
{
public IList<Bar> Bars{get;set;}
}

现在,我可以这样写吗:

public Bar Bar[int index]
{
get
{
//usual null and length check on Bars omitted for calarity
return Bars[index];
}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com