每个类多一个索引器 [英] more then one indexer per class

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

问题描述

你好


我有一个包含几个ArrayList的类,我想为每个使用一个

索引器。我收到了编译错误。


已经定义了一个名为''this''的成员,其参数类型相同

可以任何一个建议:

我可以判断一个以上的索引器吗?


谢谢

Yoramo

解决方案



" Yoramo" <哟**** @ hotmail.com>在消息中写道

新闻:eT ************** @ TK2MSFTNGP10.phx.gbl ...

你好

我有一个包含几个ArrayList的类,我想为每个使用一个
索引器。我收到了编译错误。

已经定义了一个名为''this''的成员,其参数类型相同

可以任意一个建议:与方法类似,索引器只能通过参数重载。你可以做这个[int index];

公共对象这个[字符串名称];

等,但是b $ b公共对象,但是你不能用相同的参数列表创建两个索引器。
谢谢你们Yoramo



谢谢


从一个对象公开数组的正确方法是什么?

我不喜欢GetXXX(int indx)类型的方法。你有更好的解决方案吗?


Yoramo


Daniel O''Connell < onyxkirx @ - NOSPAM--comcast.net>在消息中写道

news:uy ************** @ TK2MSFTNGP12.phx.gbl ...


" ; Yoramo" <哟**** @ hotmail.com>在消息中写道
新闻:eT ************** @ TK2MSFTNGP10.phx.gbl ...

你好

我有一个包含几个ArrayList的类,我想为每个使用
a索引器。我收到了编译错误。

已经定义了一个名为''this''的成员,其参数类型相同

可以任意一个建议:


类似于方法,索引器只能通过参数重载。你可以做这个[int index];
公共对象这个[string name];
等,但你不能创建两个具有相同参数列表的索引器。 blockquote class =post_quotes>
感谢
Yoramo




艰难。使用方法。

Yoramo <哟**** @ hotmail.com>在消息中写道

新闻:#K ************** @ TK2MSFTNGP12.phx.gbl ...

谢谢

从一个对象公开数组的正确方法是什么?
我不喜欢GetXXX(int indx)类型的方法。你有更好的解决方案吗?

Yoramo

Daniel O''Connell < onyxkirx @ - NOSPAM--comcast.net>在消息中写道
新闻:uy ************** @ TK2MSFTNGP12.phx.gbl ...


" Yoramo" <哟**** @ hotmail.com>在消息中写道
新闻:eT ************** @ TK2MSFTNGP10.phx.gbl ...

你好

我有一个类包含几个ArrayList'和我想要


使用

每个的索引器。我收到了编译错误。

已经定义了一个名为''this''的成员,其参数类型相同

可以任意一个建议:


类似于方法,索引器只能通过参数重载。你可以做这个[int index];
公共对象这个[string name];
等,但你不能创建两个具有相同参数列表的索引器。 blockquote class =post_quotes>
感谢
Yoramo





Hello

I have a class the containes several ArrayList''s and I whold like to use a
indexer for each one. I''m getting a compilation error.

"already defines a member called ''this'' with the same parameter types"
can any one advice:
can I declear more then one indexer?

thanks
Yoramo

解决方案


"Yoramo" <yo****@hotmail.com> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...

Hello

I have a class the containes several ArrayList''s and I whold like to use a
indexer for each one. I''m getting a compilation error.

"already defines a member called ''this'' with the same parameter types"
can any one advice:
can I declear more then one indexer? Like methods, indexers can be overloaded by parameter only. You can do

public object this[int index];
public object this[string name];
etc, but you cannot create two indexers with the same parameter list.
thanks
Yoramo



Thanks

what is the right approach to expose arrays from one object?
I do not like the GetXXX(int indx) type of methods. do you have a better
solution?

Yoramo

"Daniel O''Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...


"Yoramo" <yo****@hotmail.com> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...

Hello

I have a class the containes several ArrayList''s and I whold like to use a indexer for each one. I''m getting a compilation error.

"already defines a member called ''this'' with the same parameter types"
can any one advice:
can I declear more then one indexer?


Like methods, indexers can be overloaded by parameter only. You can do

public object this[int index];
public object this[string name];
etc, but you cannot create two indexers with the same parameter list.


thanks
Yoramo




Tough. Use a method.
"Yoramo" <yo****@hotmail.com> wrote in message
news:#K**************@TK2MSFTNGP12.phx.gbl...

Thanks

what is the right approach to expose arrays from one object?
I do not like the GetXXX(int indx) type of methods. do you have a better
solution?

Yoramo

"Daniel O''Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...


"Yoramo" <yo****@hotmail.com> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...

Hello

I have a class the containes several ArrayList''s and I whold like to

use

a indexer for each one. I''m getting a compilation error.

"already defines a member called ''this'' with the same parameter types"
can any one advice:
can I declear more then one indexer?


Like methods, indexers can be overloaded by parameter only. You can do

public object this[int index];
public object this[string name];
etc, but you cannot create two indexers with the same parameter list.


thanks
Yoramo





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

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