Friday, 16 November 2012

Variables Using C sharp

Variables Using C sharp:

Computer programmes work by manipulating data stored in memory. These storage buckets come under the general heading of Variables. Now we see how to set up and use variables. After some lessons, we will create our own calculator programme using c Sharp dot net frame work.lets get started with Strings.


Strings:

              Strings are the variables that hold " text ". 

Concept:

            to understand the concept of strings variable we take an example of some buckets.
lets spouse we have 5 buckets  these buckets will remain empty until we put some thing in them.
And we can also write some names on them so we know what they contain.   

Lets code:

For better under standing lets create a  new programme.

Step 1:

            Open new Project by clicking on New Project.

Step 2:

Our Form should look like this

              

Step 3:

           Now we will  go to toolbox and add a new button to our form.



         

Step 4:

          Chang the text of Button form buttons properties.
Now form looks like this.


Step 5:

          Now again lets go to toolbox and add a new textbox to our form.Our form should look like this.



Step 6:

         Double click on Message box button to add some code to it.





There we have to code so we can :
1. Create and variable
2. Assign a value to variable 
3. Out put the value of variable.




1. Creating a string variable:

            string Name;
This code creates a string variable or a bucket that can hold some text data and it's name is "Name"   
2. Assigning a value to String Variable (Name):
            Name = textBox1.Text;
            This Code gives the value or Text of textbox1 to Name (String Variable).
3. Out Putting the Value Saved in String variable "Name".                   
            MessageBox.Show("Your Name is "+Name);         

           This code out puts the Value saved in Name via a Message box
Now run your programme and keep coding best of luck.

No comments:

Post a Comment