For example:
car Audi = new car();
Is it possible to something like this:
string name = Microsoft.VisualBasic.Interaction.Input
The only way I can think of doing it is a C# version of
car = Car() //basically Python way of initializing car
del car
car = Thing()
No, you can't. In C# variables must be known at compile time, together with their names...
What you can do is have a collection where to put all your cars... Like:
var allmycars = new Dictionary<string, Car>();
string name = Microsoft.VisualBasic.Interaction.InputBox("Name of new car?", "Add car");
car mycar = new car();
allmycars.Add(name, mycar);
then you can:
foreach (KeyValuePair<string, car> onecar in allmycars)
{
string name2 = onecar.Key;
car car2 = onecar.Value;
Console.WriteLine(name2);
}
No you cannot do that. But you can use a different data structure for something similar.
Use Dictionary
Dictionary<string, car> dictionary = new Dictionary<string,car>();
if(!dictionary.ContainsKey(name))
{
dictionary.Add(name, new car());
}
This isn't possible as variable names are converted to addresses in memory whenever you compile the program.
Since you're trying to name the variable after you compiled the program during runtime, it wouldn't make a difference since it's no longer a human readable name.