通过类的成员迭代,不知道有多少 [英] Iterate through members of a class, without knowing how many are

查看:78
本文介绍了通过类的成员迭代,不知道有多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个班级。

我需要在这个班级写一个例程,循环通过它的成员(在班级的b $ ba实例中)和将所有成员值连接为字符串。

我需要过滤使用自定义属性的成员(找到方法),所以只有

其中一些被认为是添加到最后的字符串。


困难的部分是一些成员是他们自己的类实例,并且应该为他们调用相同的方法,返回的字符串应该是

添加到最后一个字符串


对任何人有任何意义吗? :)


-

Ceers,

Crirus


--- ---------------------------

如果工作是件好事,那么老板就会把这一切都拿走


------------------------------

I have a class.
I need to write a routine in this class, that loop through it''s members (in
a instance of the class) and concatenate all members values as string.
I need to filter does members with a custom attribute (found a way), so only
some of them are considered to be added to final string.

The hard part is that some members are class instances them selfs and the
same method should be called for them and the returning string should be
added to the final string

Make any sence to anybody? :)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

推荐答案

没有人?


-

Ceers,

Crirus


------------------------------

如果工作是好事,那么老板就会把这一切都从你身上拿走


----------------------- -------


" Crirus" <铬**** @ datagroup.ro>在消息中写道

news:%2 ****************** @ TK2MSFTNGP12.phx.gbl ...
No one??

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
我有一个类。
我需要在这个类中编写一个例程,循环遍历它的成员
(在类的实例中)并将所有成员值连接成字符串。
我需要使用自定义属性(找到方法)过滤成员,所以
只考虑其中一些被添加到最终字符串。

困难的部分是一些成员是类实例,他们自己和
相同的方法应该为他们调用,返回的字符串应该被添加到最后的字符串

任何人的任何一个? :)

-
Ceers,
Crirus

------------------- -----------
如果工作是好事,老板就会把这一切都从你身上拿走

------------ ------------------
I have a class.
I need to write a routine in this class, that loop through it''s members (in a instance of the class) and concatenate all members values as string.
I need to filter does members with a custom attribute (found a way), so only some of them are considered to be added to final string.

The hard part is that some members are class instances them selfs and the
same method should be called for them and the returning string should be
added to the final string

Make any sence to anybody? :)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------



>>通过它''成员(在班级的一个实例中)<<


这一点令人困惑......
>>through it''s members (in a instance of the class) <<

This bit is confusing...


" Crirus" ; <铬**** @ datagroup.ro>写了......
"Crirus" <Cr****@datagroup.ro> wrote...
我有一个班级。
我需要在这个班级写一个例程,循环通过它的成员
(在一个这个类的实例)并将所有成员值连接成字符串。
I have a class.
I need to write a routine in this class, that loop through it''s members (in a instance of the class) and concatenate all members values as string.




我建议你描述你的最终目标...而不是你需要什么? />
写但你需要做什么做。这听起来有点像你在寻找序列化解决方案的b $ b但谁知道呢?经常发生的是

发布的问题很容易通过不攻击来解决,如果来自

那个方向。


Tom



I''ll suggest that you describe your ultimate goal... not what you need to
write but rather what you need to "do." It sounds a little like you are
looking for a serialization solution but who knows? What often happens is
that problems are posted which can easily be solved by not attacking if from
that direction.

Tom


这篇关于通过类的成员迭代,不知道有多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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