索引 [英] Indexers

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

问题描述

在框架的更高版本中,是否可以在成员字段上使用

属性的索引器?


比如说我有


私人ArrayList blah;


和一个项目


公共对象Blah [int index]

{

get {return blah [index]; }

}

解决方案

Alvin,

In更高版本的框架是否可以在成员字段的属性上使用索引器?




编号但这是C#语言限制。


Mattias


-

Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/

请仅回复新闻组。


是否会添加或有充分理由不这样做?


既然属性仍然是方法,我没有看到他们为什么不能获得b

" Mattias Sj?gren的技术原因。 <毫安******************** @ mvps.org>在消息中写道

新闻:Ow ************** @ TK2MSFTNGP09.phx.gbl ...

Alvin,

在框架的后续版本中,是否可以在成员字段的
属性上设置索引器?



否。这是一个C#语言限制。

Mattias

-
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
请仅回复新闻组。



Alvin,

它会被添加还是有充分的理由没有这个?


Ever是很长一段时间,因为除了惠德贝发布之外什么都没有宣布,我不会告诉任何事情。它可能也是

取决于客户的需求。


既然属性是方法,我也没有看到技术上的原因,为什么它们不能被授予 / blockquote>


虽然它们在技术上是以这种方式实现的,但我认为概念上

的属性和方法是非常不同的。


Mattias


-

Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/

请仅回复新闻组。


In later versions of the framework is it possible to have indexers on
properties for member fields?

Say for example I have

private ArrayList blah;

and a propget

public object Blah[int index]
{
get { return blah[index]; }
}

解决方案

Alvin,

In later versions of the framework is it possible to have indexers on
properties for member fields?



No. But this is a C# language limitation.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.


Will it ever be added or is there a good reason for not having this?

Since propertys are methods anyway, I dont see a technicaly reason why they
cannot be permited

"Mattias Sj?gren" <ma********************@mvps.org> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...

Alvin,

In later versions of the framework is it possible to have indexers on
properties for member fields?



No. But this is a C# language limitation.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Alvin,

Will it ever be added or is there a good reason for not having this?
"Ever" is a long time, and since nothing beyond the Whidbey release
has been announced, I don''t thing anyone can tell. It probably also
depends on customer demand.

Since propertys are methods anyway, I dont see a technicaly reason why they
cannot be permited



While they technically are implemented that way, I think conceptually
properties and methods are very different.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.


这篇关于索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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