0

Hello,

I have two classes, stnt_1 and stnt_2 of the same type. Is it possible for me to call these from a loop? where 1 and 2 are the iterations of the loop control variable.

Other words, say that class had a displayString() method, is there a way for me to do this:

for (int i = 1;i>=2;i++)
(
[INDENT]Console.Writeline(stnt_ [B]+ i +[/B] .displayString();[/INDENT]
)

I am at a loss on what this would be called and as a result google has not pointed me in the correct direction. Is there a way in c# to evaluate i first, then join it to get the desired result?

Thanks for taking the time to read this.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
0

Look into arrays and generic lists.

And to correct your wording, you do not have two classes of the same type. The type is the class. You have two objects of the same type. The class is the definition, the object is the intantiation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.