title: How to create an object with name from string?
body: <p>So when I create an object, I use something like:</p>
  
  <pre><code>Object objectName = new Object();
  </code></pre>
  
  <p>And I get an object which I can refer to as objectName when calling methods like </p>
  
  <pre><code>objectName.method(parameter);
  </code></pre>
  
  <p>But how do I make it so I can create an object that I can refer to using a name from a string, something like:</p>
  
  <pre><code>string objectName = "myName";
  Object [objectName] = new Object();
  </code></pre>
  
  <p>And then refer to it like:</p>
  
  <pre><code>myName.method(parameter);
  </code></pre>
  
  <p>So somehow insert the string objectName into the actual name of the new object.
  How would I do this?</p>
  
  <p>EDIT: I stumbled across this question in my own profile 5 years (and a CS degree) later, and laughed. The use-case for this was creating objects to store data about locations in a video game world, and I didn't at the time realize that you could have objects without names. The solution I actually would have needed would simply have been an array of objects.</p>