Results 1 to 3 of 3

Thread: creating ten uniquely named objects

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Location
    Bristol/Bath
    Posts
    85

    creating ten uniquely named objects

    I want to create ten objects within a loop, each object obviously should have a unique name

    I am creating ten instances of TestObject

    Code:
     for (int i = 0; i < 10; i++) 
            {
                TestObj UNIQUENAME = new TestObj();
            }
    how do i create a unique name using the loop counter i eg TestObj1, TestObj2 etc
    VS.Net Pro 2003, .NET 1.1

    My Photography portfolio:
    http://www.ephotozine.com/user.cfm?user=24834

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: creating ten uniquely named objects

    Create an array of objects, so that you don't need a name, but an ordinal reference to the object's position in the array.

  3. #3
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843

    Re: creating ten uniquely named objects

    Quote Originally Posted by mendhak
    Create an array of objects, so that you don't need a name, but an ordinal reference to the object's position in the array.

    I'd do something like that too.
    Merry Christmas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width