Q
Problem solve Get help with specific problems with your technologies, process and projects.

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.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close