I am trying to make a query system for objects, but I have been unable to figure out how to turn a string from Console.ReadLine()
to an object's name. Here is an example code snippet:
class Program
{
Notes note = new Notes();
note.notes = "note";
Notes note2 = new Notes();
note2.notes = "note2";
Console.WriteLine("which note would you like?");
string which = Console.ReadLine();
if(which.ToUpper == ("NOTE" || "NOTE2")
{
Console.WriteLine(which + "\'s note is " + which.note);//this is where I need to find an object from a string
}else
{
Console.WriteLine("There is no note called " + which);
}
}
class Notes
{
string notes;
}
For context, I intend to add a lot more objects into this and a large amount of if
statements to find the right object will not be very practical
If I need to be more clear, please say so. Thanks for any help you can give.