dynamic object name creation

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

Hello,
I am trying to do the following:
for (int x = 0; x < GraphData.Length; x++)
{
CreateGraph((zedGraphControl+x), GraphData[x]);
//CreateGraph(zedGraphControl1, GraphData[1]);//The
old way before it was dynamic
//CreateGraph(zedGraphControl2, GraphData[2]);
//CreateGraph(zedGraphControl3,
GraphData[3]);..............

But of course it isnt working.
It gives me an Error The name 'zedGraphControl' does not exist in the
current context.
How do I append the "x" to the name?
Thanks
Mike
 
AMP said:
Hello,
I am trying to do the following:
for (int x = 0; x < GraphData.Length; x++)
{
CreateGraph((zedGraphControl+x), GraphData[x]);
//CreateGraph(zedGraphControl1, GraphData[1]);//The
old way before it was dynamic
//CreateGraph(zedGraphControl2, GraphData[2]);
//CreateGraph(zedGraphControl3,
GraphData[3]);..............

But of course it isnt working.
It gives me an Error The name 'zedGraphControl' does not exist in the
current context.
How do I append the "x" to the name?

You don't. Instead of having several variables, have an array and index
into it.
 
Back
Top