Hello and welcome.
In this section we are going to learn about variables and data types.
We have played around with it in our earlier section where we created our first web app.
We use some variables and we used also some data types.
We created a variable or variables.
We also use data a data type.
During our lecture where we created a basic Web page that included a web form.
So we use things like a string a string basically is a data type.
It's a type of data before you declare a variable in C sharp.
You need to specify what type of data it is so that you know it knows what is playing with or what is
dealing with.
So the string here is the first thing you specify you specified the data type which is a string which
means it's going to be a text followed by the name of the variable.
OK.
And then once you give the variable name you use the assignment operator which is the equals to sign
to give the variable a name or a value.
In this case the value is Rick because it's a string you must enclose it in quotes.
So you either use double quotes or single quotes.
You can't mix them.
You can't use a double here and then use a single here.
The quotes have to match let's have a look at how you declare variables and assign values to them.
We've already tried this in our lecture where we created the web form.
Let's see how we do that.
A variable is a container to store value.
So a variable will store a single value.
So for example let's say this is our container here before we store anything we need to know what type
of data we are story.
So first of all would give the variable or a name.
This is a container.
We give it a name called first name.
Then we need to know what type of data we are going to store inside this container is going to be a
string.
OK.
So we've determined the name of identified the type of content or data is going to store.
So we can mix them.
Have already this time in the skin to store a string which is a text.
The next thing will be to assign a value to the variable or add something to it.
So we assign a value using the equals to sign which is the assignment operator.
So for this illustration purposes abuse an arrow instead to substitute for that equals to sign.
Then we'll assign a value the value for example I give it a name Rick.
So now we have declared the variable first of all we gave it a name.
We determine the type of data and then we assigned a value.
So let's look at the example we did when we created the form so this is our piece of code here from
where we created our web form.
So we notice here on line 19 this is the right format.
This is where you should declare a variable.
You start with a data type.
The data type in this is a string.
So I've identified what I'm going to store is going to be a string.
Then I gave the variable in name which is then I use the assignment operator which is equal to to give
the variable a value.
And I'm giving the variable a value of first name box.
So that means whatever we type into that box first name will be the value.
Same thing here on line 20.
It's exactly the same thing.
So that's basically how you will declare and assign value to a variable in the data type first which
is string followed by the name and then you assign a value and then you give the value.
So this should be the right format string.
If you if you're if your story your variable is gonna be a string you need a specified first followed
by the name given a variable the variable and then an assignment operator.
You used that to give the variable a value.
OK.
So in this case I used that I'm giving it a value of break and then you have to use a semicolon to terminate
it to end the statement and this is one statement.
I almost ended with a semicolon to read notice here in the code all these statements.
Every line here ends with a semicolon.
That means the when the code is being read the computer will know that that's the end of phone call.
One line of code it jumps onto the other line so you need to use a semicolon to determine just like
when you read in a book you need You need the full stop to know that the paragraph stops there and.
So semicolon is used by the computer when the code is being compiled to know that this is one statement
one line of code.
This is another line of code.
And so.