c# - How can I name the array after the user input? -
i trying name array client name beingness input staff, input , spaces such 'john smith' hence whitespace needs removed become johnsmith. have tried looking on google didn't find meaningful results
{
public form1() { initializecomponent(); } private void clientaddress_click(object sender, eventargs e) { } private void addbutton_click(object sender, eventargs e) { if (userinput.text == "") { messagebox.show("empty field!"); } else if (listbox.items.contains(userinput.text)) { messagebox.show("name taken!"); } else { string clientname = userinput.text.replace(" ", string.empty); string[] clientname = new string { { userinput.text, "unknown", "unknown" } }; } } }
}
you cannot dynamically name variable in application. can utilize user typed in key in dictionary class.
// lets have dictionary client list string[] clientdata = new string { { userinput.text, "unknown", "unknown" } }; clientlist.add(userinput.text, clientdata);
c# arrays
No comments:
Post a Comment