Say I have a class who's constructor takes its values from data read from a file, is it also possible to create an instance of that class with a name from a string. That way I can create an instance of a class for each file I open and the constructor can be automatically loaded.
//User chooses file to open
//Read ChocolateCake.txt values
string className = Path.GetFileName(path);
//code to remove .txt
//Instance name is taken from className
Cake "ChocolateCake" = new Cake(ingredient1, ingredient2, etc);
How would I create an instance of Cake with the name of the file I have read?
classNamebut use a string literal"ChocolateCake"? But even if you fix that, why does the variable name matter at all(Sayse's comment)? It sounds as if you want to store those cakes by name. Then use aDictionary<string, Cake>as Richard has suggested in his answer.