Creating string arrays from textboxes
I have 3 textboxes in my UserControl (tbName1, tbName2, tbName3). I want to make a property (NameArray) as a type of string[] so that i can get/set the text properties of the textboxes using indices.
In other words:
this.myUserControl.NameArray[0] = "Alan"; Console.WriteLine(this.myUserControl.NameArray[1]);How do I write this property?
This is a simple task of creating an array of strings containing the text contained in the textboxes. You can achieve a property by using a property like the one below:
public string[] Names { get { return new string[] {tbName1.Text, tbName2.Text, tbName3.Text}; } }
Dig Deeper on C# programming language
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.
Meet all of our Microsoft .Net Development experts
Start the conversation
0 comments