Variables en c#

Solo disponible en BuenasTareas
  • Páginas : 3 (706 palabras )
  • Descarga(s) : 0
  • Publicado : 21 de noviembre de 2011
Leer documento completo
Vista previa del texto
Programmes work by manipulating data stored in memory. These storage areas come under the general heading of Variables. In this section, you'll see how to set up and use variables. You'll see how toset up both text and number variables. By the end of this section, you'll have written a simple calculator programme. We'll start with something called a String variable.



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....
tracking img