1
00:00:00,690 --> 00:00:01,620
Hello and welcome.

2
00:00:01,620 --> 00:00:07,430
In this section we are going to learn about variables and data types.

3
00:00:07,710 --> 00:00:17,190
We have played around with it in our earlier section where we created our first web app.

4
00:00:17,220 --> 00:00:24,270
We use some variables and we used also some data types.

5
00:00:24,270 --> 00:00:27,660
We created a variable or variables.

6
00:00:27,660 --> 00:00:30,970
We also use data a data type.

7
00:00:31,020 --> 00:00:38,580
During our lecture where we created a basic Web page that included a web form.

8
00:00:38,820 --> 00:00:44,970
So we use things like a string a string basically is a data type.

9
00:00:44,970 --> 00:00:49,410
It's a type of data before you declare a variable in C sharp.

10
00:00:49,410 --> 00:00:57,750
You need to specify what type of data it is so that you know it knows what is playing with or what is

11
00:00:58,320 --> 00:00:59,340
dealing with.

12
00:00:59,340 --> 00:01:06,150
So the string here is the first thing you specify you specified the data type which is a string which

13
00:01:06,150 --> 00:01:12,490
means it's going to be a text followed by the name of the variable.

14
00:01:12,510 --> 00:01:13,320
OK.

15
00:01:13,380 --> 00:01:20,160
And then once you give the variable name you use the assignment operator which is the equals to sign

16
00:01:20,880 --> 00:01:25,500
to give the variable a name or a value.

17
00:01:25,500 --> 00:01:34,270
In this case the value is Rick because it's a string you must enclose it in quotes.

18
00:01:34,390 --> 00:01:37,060
So you either use double quotes or single quotes.

19
00:01:37,080 --> 00:01:38,940
You can't mix them.

20
00:01:38,940 --> 00:01:41,870
You can't use a double here and then use a single here.

21
00:01:42,090 --> 00:01:51,850
The quotes have to match let's have a look at how you declare variables and assign values to them.

22
00:01:51,890 --> 00:01:58,500
We've already tried this in our lecture where we created the web form.

23
00:01:58,560 --> 00:02:00,050
Let's see how we do that.

24
00:02:01,310 --> 00:02:06,200
A variable is a container to store value.

25
00:02:06,580 --> 00:02:10,820
So a variable will store a single value.

26
00:02:10,820 --> 00:02:20,540
So for example let's say this is our container here before we store anything we need to know what type

27
00:02:20,540 --> 00:02:22,390
of data we are story.

28
00:02:22,940 --> 00:02:27,670
So first of all would give the variable or a name.

29
00:02:27,680 --> 00:02:29,090
This is a container.

30
00:02:29,090 --> 00:02:31,240
We give it a name called first name.

31
00:02:31,460 --> 00:02:38,960
Then we need to know what type of data we are going to store inside this container is going to be a

32
00:02:38,960 --> 00:02:39,800
string.

33
00:02:40,580 --> 00:02:41,430
OK.

34
00:02:41,450 --> 00:02:51,050
So we've determined the name of identified the type of content or data is going to store.

35
00:02:51,290 --> 00:02:52,630
So we can mix them.

36
00:02:52,660 --> 00:02:57,370
Have already this time in the skin to store a string which is a text.

37
00:02:57,390 --> 00:03:05,270
The next thing will be to assign a value to the variable or add something to it.

38
00:03:06,080 --> 00:03:12,310
So we assign a value using the equals to sign which is the assignment operator.

39
00:03:12,590 --> 00:03:22,330
So for this illustration purposes abuse an arrow instead to substitute for that equals to sign.

40
00:03:22,550 --> 00:03:28,460
Then we'll assign a value the value for example I give it a name Rick.

41
00:03:28,490 --> 00:03:33,660
So now we have declared the variable first of all we gave it a name.

42
00:03:33,830 --> 00:03:40,430
We determine the type of data and then we assigned a value.

43
00:03:40,430 --> 00:03:48,710
So let's look at the example we did when we created the form so this is our piece of code here from

44
00:03:48,710 --> 00:03:51,430
where we created our web form.

45
00:03:52,370 --> 00:03:56,180
So we notice here on line 19 this is the right format.

46
00:03:56,180 --> 00:03:59,060
This is where you should declare a variable.

47
00:03:59,210 --> 00:04:01,150
You start with a data type.

48
00:04:01,220 --> 00:04:03,590
The data type in this is a string.

49
00:04:03,590 --> 00:04:08,520
So I've identified what I'm going to store is going to be a string.

50
00:04:08,630 --> 00:04:16,730
Then I gave the variable in name which is then I use the assignment operator which is equal to to give

51
00:04:16,730 --> 00:04:19,020
the variable a value.

52
00:04:19,230 --> 00:04:24,340
And I'm giving the variable a value of first name box.

53
00:04:24,380 --> 00:04:30,230
So that means whatever we type into that box first name will be the value.

54
00:04:30,230 --> 00:04:32,490
Same thing here on line 20.

55
00:04:32,530 --> 00:04:33,890
It's exactly the same thing.

56
00:04:33,890 --> 00:04:42,320
So that's basically how you will declare and assign value to a variable in the data type first which

57
00:04:42,320 --> 00:04:48,770
is string followed by the name and then you assign a value and then you give the value.

58
00:04:50,120 --> 00:04:53,180
So this should be the right format string.

59
00:04:53,420 --> 00:04:59,390
If you if you're if your story your variable is gonna be a string you need a specified first followed

60
00:04:59,390 --> 00:05:05,860
by the name given a variable the variable and then an assignment operator.

61
00:05:05,870 --> 00:05:09,320
You used that to give the variable a value.

62
00:05:09,840 --> 00:05:10,490
OK.

63
00:05:10,640 --> 00:05:18,240
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

64
00:05:18,250 --> 00:05:21,700
it to end the statement and this is one statement.

65
00:05:21,860 --> 00:05:27,680
I almost ended with a semicolon to read notice here in the code all these statements.

66
00:05:27,710 --> 00:05:30,230
Every line here ends with a semicolon.

67
00:05:30,230 --> 00:05:36,200
That means the when the code is being read the computer will know that that's the end of phone call.

68
00:05:36,200 --> 00:05:41,960
One line of code it jumps onto the other line so you need to use a semicolon to determine just like

69
00:05:41,960 --> 00:05:47,620
when you read in a book you need You need the full stop to know that the paragraph stops there and.

70
00:05:47,660 --> 00:05:56,750
So semicolon is used by the computer when the code is being compiled to know that this is one statement

71
00:05:56,780 --> 00:05:57,620
one line of code.

72
00:05:57,620 --> 00:05:59,450
This is another line of code.

73
00:05:59,450 --> 00:05:59,960
And so.
