Is there any way of naming a object from a variable?
I know in PHP this is easely done since variables has a $ infront of them.
Using PHP Variables in C# (if this was possible):
$varName = "myBook";
Book $varName = new Book()
It will be named what the variable $varName contains.
Using C#:
string varName = "myBook";
Book varName = new Book();
This will produce an error saying you cant convert varName from string to Book since its allready defined.
So what am I looking for?
A way to name Objects from Variables. The objects NAME (Book NAME = new Book();) should be named what the variable contains!
Thx for any help or information.
Loading
strandbergPosted Nov 4, 2006, 4:47 PM
Noone know anything about this? I think its very VERY usefull to be able to name things after whats inside a variable so if anyone knows. Please do tell.
strandbergPosted Nov 1, 2006, 8:44 AM
I wanna name the object after whats INSIDE the variable.
I want to the book object to be named "myBook", not varName.
I want it to look like this:
Book myBook = new Book();
but I want to use the variable varName instead of writing 'myBook'.
Scott LyslePosted Oct 26, 2006, 9:48 PM