I’m coming into C# from the JavaScript language and I can’t seem to find a way to assign string ID names to objects in my Form application that can be used in many methods. For example,
string inputNameBox = textbox1.Text;
I want to be able to use “inputNameBox” in any method. If I assign inputNameBox inside a click event for a button, everything works properly. But I want to be able to call inputNameBox in another method without giving a new string ID to textbox1.Text.
I tried using static strings and constants, but they returned error. I also tried setting them as properties but the value = null.
How can I use the same string ID for the .Text object in any method?
use a property: