3 Replies - 1223 Views - Last Post: 13 June 2010 - 06:47 AM Rate Topic: -----

#1 Guest_b.thibodeaux75@gmail.cpm*


Reputation:

Using a variable's value as another variable's name

Posted 12 June 2010 - 07:37 PM

Hi guys,
New to programming. I've played with a few languages.
My question is this. In PHP there is a way to use one variable's value as another variable's name.
Something like this
$a = 'thibodeaux';
${$a} = 32;
$a is assigned the string value 'thibodeaux'. Then the variable $thibodeaux is assigned the value of 32.
Is it possible to do this in C#?
Thanks in advance for the help.
Bart

Is This A Good Question/Topic? 0

Replies To: Using a variable's value as another variable's name

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Using a variable's value as another variable's name

Posted 12 June 2010 - 09:17 PM

No. There's no way you could do this with C#. And I (personally) don't see the point of this technique anyway.

This post has been edited by sarmanu: 12 June 2010 - 09:28 PM

Was This Post Helpful? 0
  • +
  • -

#3 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 497
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: Using a variable's value as another variable's name

Posted 13 June 2010 - 05:06 AM

100% agree with sarmanu, would be easier to just declare them normally. I dont see why you have to have a specific name 'thibodeaux' for the variable. Its what the variables hold thats more important rather than defining them. Defining a variable is just a way of you to control how you use the data it holds.

Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#4 Vermiculus  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 10
  • View blog
  • Posts: 314
  • Joined: 26-February 09

Re: Using a variable's value as another variable's name

Posted 13 June 2010 - 06:47 AM

Agreed. After all, after compilation the variable names become indecipherable - they have no real purpose in the program except to refer to a memory location.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1