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.

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.

>How do I evaulate a variable first, then join it to something.

Reflection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.