Variables en c#
String Variables inC#.NET
The first type of variable we'll take a look at is called a String. String variables are always text. We'll write a little programme that takes text from a text box, store the text in avariable, and then display the text in a message box.
But bear in mind that a variable is just a storage area for holding things that you'll need later. Think of them like boxes in a room. The boxes areempty until you put something in them. You can also place a sticker on the box, so that you'll know what's in it. Let's look at a programming example.
If you've got your project open from theprevious section, click File from the menu bar at the top of Visual C#. From the File menu, click Close Solution. Start a new project by clicking File again, then New Project. From the New Projectdialogue box, click on Windows Application. For the Name, type String Variables.
Click OK, and you'll see a new form appear. Add a button to the form, just like you did in the previous section. Click onthe button to select it (it will have the white squares around it), and then look for the Properties Window in the bottom right of Visual Studio. Set the following Properties for your new button:Name: btnStrings
Location: 90, 175
Size: 120, 30
Text: Get Text Box Data
Your form should then look like this:
We can add two more controls to the form, a Label and a Text Box. When the buttonis clicked, we'll get the text from the text box and display whatever was entered in a message box.
A Label is just that: a means of letting your users know what something is, or what it is for....
Regístrate para leer el documento completo.