Naming an Instance of a class
Good afternoon,
I'm having trouble figuring out how to name an instance of a class automatically. What i mean in detail is i am trying to create a recipe book that a user can put in a name, ingredients and other things... having the instance of the class created on a button press. which means creating the instance Recipe name = new Recipe() ect ect... how can i have the name be created dynamically and not physically?
What you're thinking requires a language that does not rely upon compilation in order implement new code, and C# is not that language.
$$anonymous$$y reaction, as a long time developer, is that this isn't necessary anyway. There's not much of a purpose served. Ins$$anonymous$$d, what you really need is a container, like a List or Dictionary, which stores classes of type Recipe that include the name you're imagining as a property or member of the class, not the name of the instance.
Thank you JVene, I was just co$$anonymous$$g in here to either remove the question or to answer it. For some reason i thought i had to name each instance of the class prior to putting it into the list. However, I have found that I do NOT need to do that. Thank you for your response!
Answer by scoobz1234 · Sep 16, 2018 at 12:00 AM
Refer to @JVene 's reply, as It's best suited to answer this question.
Further: I found it's not necessary to name an instance of the class prior to adding it to a list.
Your answer
Follow this Question
Related Questions
Problems with dynamically adding and scrolling to Scrollview 0 Answers
Best way to reference player class instance? 1 Answer
Dynamically added UI text is not displaying 2 Answers
Adding a prefab to the Item class instance 0 Answers
Is it possible to use Dinamicaly generated characters instead of prefabs in/for NetworkManager? 0 Answers