1
00:00:00,800 --> 00:00:07,730
In this video we're going to be creating our projects that will receive user input and print some outputs.

2
00:00:07,760 --> 00:00:12,980
I'm starting from our folder where our project was created because maybe you shut down the machine you

3
00:00:12,980 --> 00:00:13,970
went to have dinner.

4
00:00:14,000 --> 00:00:19,250
It's been days since you were last in Visual Studio and so I just want to show you how you can relaunch

5
00:00:19,250 --> 00:00:25,760
your project from the file system and you know not to have to go into Visual Studio and source it so

6
00:00:26,060 --> 00:00:30,880
I can just go back to the file system find the solution and double click.

7
00:00:31,250 --> 00:00:38,090
That will launch results to you and that will relaunch our project our solution with our project and

8
00:00:38,090 --> 00:00:39,290
everything that we were doing.

9
00:00:39,290 --> 00:00:45,470
So every time you go ahead and you correct code and you save and you relaunch a solution it may relaunch

10
00:00:45,470 --> 00:00:50,790
with all of the tabs yard open or the court files and all the projects and everything that you know

11
00:00:50,930 --> 00:00:56,900
let's go about putting a new project inside this solution so that we can test or write a new program.

12
00:00:56,900 --> 00:01:04,250
So this was our hello world program notice at a comment here at some static takes or some random text

13
00:01:04,250 --> 00:01:06,330
that was giving problems that just come into default.

14
00:01:06,530 --> 00:01:10,040
But that's it for the whole world so let's move on to a new one.

15
00:01:10,060 --> 00:01:14,750
Someone to write the solution note not the project.

16
00:01:14,750 --> 00:01:20,870
This is the project I'm right clicking the solution so or I notice that it's really just a config file

17
00:01:20,890 --> 00:01:21,170
right.

18
00:01:21,560 --> 00:01:28,460
So I'm right clicking the solution and with the click add and then I'm going to see new project then

19
00:01:28,460 --> 00:01:32,870
it brings back this menu that we should be familiar with this dialog box that we should be familiar

20
00:01:32,870 --> 00:01:36,110
with asking Okay what kind of project do you want this time.

21
00:01:36,110 --> 00:01:43,370
So I'm going to select once again console up dot net core click next and then this time I want the project

22
00:01:43,370 --> 00:01:50,380
need to be input output so input outputs lots of spelling errors.

23
00:01:50,390 --> 00:01:53,050
So you want to make sure that you write it properly right.

24
00:01:53,090 --> 00:01:54,390
Naming is important.

25
00:01:54,560 --> 00:01:59,700
And then I click Create and then I get a brand new code.

26
00:01:59,730 --> 00:02:05,240
So notice it's kind of standard to come with hello world hello world is probably the first programming

27
00:02:05,240 --> 00:02:10,540
phrase that most people will ever learn when they're learning a new language how to print Hello World

28
00:02:10,550 --> 00:02:18,150
to the screen but that being said I just wanted to take some time to appreciate what is happening here.

29
00:02:18,170 --> 00:02:24,640
So notice I have a new program that seems file I still have my existing one and then so as not to make

30
00:02:24,650 --> 00:02:29,020
the mistake and let's assume that they were both identical they were both very new.

31
00:02:29,090 --> 00:02:30,860
Both of them had the same code in it.

32
00:02:30,860 --> 00:02:33,640
How do I know which one belongs to which project.

33
00:02:33,650 --> 00:02:39,080
So each time I have a console application or project you're going to get a program that's yes file and

34
00:02:39,080 --> 00:02:43,970
it's going to come with a main function and let's just say it's standard for it to say hello or that

35
00:02:43,970 --> 00:02:50,960
means we've seen that with the dot net core template we can use this dropdown list to look at which

36
00:02:50,960 --> 00:02:52,160
project it is in.

37
00:02:52,160 --> 00:02:56,150
So this program that ceasefire belongs to the hello world project.

38
00:02:56,360 --> 00:03:00,110
If I go to the next one you see that it belongs to the input output project.

39
00:03:00,110 --> 00:03:04,340
If I close them both and just does this file.

40
00:03:04,340 --> 00:03:05,780
That's a project file.

41
00:03:05,840 --> 00:03:12,260
And I have no files open then from the solution Explorer I can specifically go to which project I want

42
00:03:12,530 --> 00:03:15,530
and then select the program gutsiest file.

43
00:03:15,530 --> 00:03:15,790
All right.

44
00:03:15,820 --> 00:03:21,530
So that's all you can manage multiple projects and appreciate where what file is coming from so you

45
00:03:21,530 --> 00:03:22,380
don't make mistakes.

46
00:03:22,390 --> 00:03:28,470
Goes well you don't want to be writing input output stuff instead of hello world program dot.

47
00:03:28,490 --> 00:03:29,100
Yes.

48
00:03:29,120 --> 00:03:34,670
And then when you're running you're wondering why is your code not working or why isn't it detecting

49
00:03:34,670 --> 00:03:35,630
the code that you wrote.

50
00:03:35,640 --> 00:03:38,120
And that's just because you wrote it's in the wrong program.

51
00:03:38,120 --> 00:03:38,810
That's yes.

52
00:03:38,840 --> 00:03:41,650
So you want to be very careful and very attentive.

53
00:03:42,050 --> 00:03:46,940
And as you build more and more applications even more advanced applications you're going to have multiple

54
00:03:46,940 --> 00:03:52,150
projects we just want to be very careful unsure where each file is.

55
00:03:52,180 --> 00:03:53,240
Now let's get started.

56
00:03:53,240 --> 00:04:00,020
I did say that we wanted to write something to get user input and then print back to the screen so let

57
00:04:00,080 --> 00:04:00,700
me just remove.

58
00:04:00,710 --> 00:04:01,940
Hello world.

59
00:04:01,940 --> 00:04:03,770
So we're going to be learning a few things here.

60
00:04:03,770 --> 00:04:11,330
We're going to be learning about one variables to hold to prompt for inputs received from the user.

61
00:04:11,330 --> 00:04:15,050
And then three how to print it back to the screen.

62
00:04:15,440 --> 00:04:21,530
So let's get started with variables and I'll just put comment variables.

63
00:04:21,600 --> 00:04:23,840
A variable is like a little container.

64
00:04:23,850 --> 00:04:24,170
All right.

65
00:04:24,170 --> 00:04:30,290
So when we want data from the user we have to create a container and then we use a container to store

66
00:04:30,380 --> 00:04:32,240
the value that the user gave us.

67
00:04:32,240 --> 00:04:40,400
So for instance if I wanted a name then I need a variable and it makes sense to just call its name the

68
00:04:40,400 --> 00:04:44,050
name of my country and therefore somebody whose name is name.

69
00:04:44,090 --> 00:04:44,670
All right.

70
00:04:44,750 --> 00:04:47,900
And then further to that I need to define a type.

71
00:04:48,110 --> 00:04:51,740
So a type means the type of data that I'm expecting.

72
00:04:51,740 --> 00:04:57,370
So if I want somebodies name then that is text because they'll be writing letters.

73
00:04:57,430 --> 00:04:58,210
All right.

74
00:04:58,280 --> 00:05:04,400
So anything that's letters is a text type or a string.

75
00:05:04,400 --> 00:05:12,680
So in C sharp we call text types string when you want text from somebody you need a pocket or that container.

76
00:05:12,680 --> 00:05:17,210
And it needs to be able to store what we call a string or text.

77
00:05:17,210 --> 00:05:17,630
All right.

78
00:05:17,870 --> 00:05:20,480
So let's start off with all we declare a variable.

79
00:05:20,510 --> 00:05:24,040
I will first define the data type so C sharp eyes.

80
00:05:24,050 --> 00:05:27,610
Lots of data types and it's good to know when to use which one.

81
00:05:27,600 --> 00:05:32,190
So I just gave us a case study for the data type string.

82
00:05:32,300 --> 00:05:35,870
So I say string and then I give it the name.

83
00:05:35,870 --> 00:05:40,390
So I want some variable that is called True.

84
00:05:40,400 --> 00:05:46,740
Now it's called name sorry and it is often data type string you would have already noticed that you

85
00:05:46,740 --> 00:05:49,200
have something called string and args earlier.

86
00:05:49,200 --> 00:05:52,500
So that was the data type and args would be your variable name.

87
00:05:52,500 --> 00:05:55,500
So in this case we're making our own variable telling it that.

88
00:05:55,510 --> 00:05:55,780
OK.

89
00:05:55,800 --> 00:06:02,870
Declare a pocket in memory and call it name and it should be able to store anything that is a text.

90
00:06:02,940 --> 00:06:04,180
So I want name.

91
00:06:04,320 --> 00:06:05,170
That's one.

92
00:06:05,250 --> 00:06:11,040
So I'm going to see the clear variables and then you can have multiple variables.

93
00:06:11,040 --> 00:06:12,890
You can have as many variables as you want.

94
00:06:12,900 --> 00:06:13,170
Right.

95
00:06:13,200 --> 00:06:19,830
But then let's just keep it simple so we want name and then I'm going to want to store what the user

96
00:06:19,830 --> 00:06:27,600
is entering into the console in my pocket called names so I need to assign the data being collected

97
00:06:27,600 --> 00:06:30,630
from the console screen inside of me.

98
00:06:30,660 --> 00:06:36,510
So whenever I want to store data inside of that country you know we see a continued name or variable

99
00:06:36,510 --> 00:06:37,230
name.

100
00:06:37,230 --> 00:06:45,000
So this is name is equal to and then if I'm receiving input I'm going to call my console.

101
00:06:45,000 --> 00:06:50,610
So we get this glass console or remember that when we were printing the screen we had a console as a

102
00:06:50,610 --> 00:06:51,660
class name.

103
00:06:51,660 --> 00:06:57,840
So console once again and then I said dot and then this is all called intelligence where it's telling

104
00:06:57,840 --> 00:07:02,340
me all of the potential things I can do with my console class.

105
00:07:02,340 --> 00:07:06,600
So the thing I want to do this time last time we were writing a line.

106
00:07:06,630 --> 00:07:12,300
So if you scroll or use your right line and you see right but this time I want to read lines so you'll

107
00:07:12,300 --> 00:07:16,450
see that they have an option that is read line so I can double click that.

108
00:07:16,650 --> 00:07:19,460
And then the red line is appearing because it's saying oh yes he read line.

109
00:07:19,470 --> 00:07:24,260
But the context the syntax is not correct and that's because it's a function.

110
00:07:24,270 --> 00:07:27,760
So I need my open and close parentheses.

111
00:07:28,050 --> 00:07:30,030
Then I can use my semicolon.

112
00:07:30,030 --> 00:07:33,120
So I did say I would pay attention to the semicolon.

113
00:07:33,180 --> 00:07:38,160
Every line that you write must end with a semicolon.

114
00:07:38,160 --> 00:07:41,940
There are exceptions but for no let's just follow that rule.

115
00:07:41,940 --> 00:07:45,330
Every line that you write must have a semicolon.

116
00:07:45,330 --> 00:07:51,180
So we'll see the exceptions as we go along and relentlessly is just a matter of practice to get comfortable

117
00:07:51,180 --> 00:07:52,690
with when to use your semicolon.

118
00:07:52,860 --> 00:07:58,620
And when not to know after we've gotten the name then we want to print it back to the screen.

119
00:07:58,620 --> 00:08:00,330
So then I go to the next line.

120
00:08:00,360 --> 00:08:01,680
So this is.

121
00:08:01,680 --> 00:08:09,410
And let me just put the comments as I go along getting value from input or let me see.

122
00:08:09,480 --> 00:08:09,770
Yeah.

123
00:08:09,780 --> 00:08:15,060
Getting on store and getting and storing value from inputs.

124
00:08:15,060 --> 00:08:15,510
All right.

125
00:08:15,870 --> 00:08:18,330
So that's what we're doing in this line.

126
00:08:18,390 --> 00:08:28,210
Then the next line is printing value or values to console screen.

127
00:08:28,210 --> 00:08:32,380
So we've gotten the value and we've stored it.

128
00:08:32,380 --> 00:08:34,190
I know we want to print it back.

129
00:08:34,210 --> 00:08:37,180
So the cool thing is that I can store it.

130
00:08:37,270 --> 00:08:42,400
I can change a value and I can always manipulate whatever is in here before I printed book.

131
00:08:42,520 --> 00:08:45,940
And that's the value of having the the variables.

132
00:08:45,940 --> 00:08:48,370
So no I want to bring it back to screen and we did.

133
00:08:48,370 --> 00:08:53,410
We printed the screen already we did for intel world so we can just follow that same pattern and we

134
00:08:53,410 --> 00:08:55,350
see a console dot.

135
00:08:55,420 --> 00:08:56,980
And remember the print was right.

136
00:08:56,980 --> 00:09:03,700
Line and see intelligence is helping me right line and then it's a function so I need my parentheses

137
00:09:03,730 --> 00:09:09,590
and then they're coordinating me and telling me that OK what do you need inside here is a string value.

138
00:09:09,610 --> 00:09:15,740
So we did put hello world inside quotation marks and that's what a string is it's text like I said.

139
00:09:15,760 --> 00:09:22,270
So whenever one takes we need to open and close quotation marks and then we can type anything we want

140
00:09:22,540 --> 00:09:26,440
any alphanumeric sequence any special characters we want.

141
00:09:26,440 --> 00:09:31,730
Once they're inside of quotation marks see sharp we'll say Well that is static.

142
00:09:31,730 --> 00:09:37,210
I'm not supposed to touch that because that is what my master being you wants me to print.

143
00:09:37,210 --> 00:09:37,780
All right.

144
00:09:37,900 --> 00:09:45,650
So I'm going to remove this and I'm going to so I can put the sentence you know anything I want.

145
00:09:45,660 --> 00:09:50,220
We did see a Hello World last time but what I want to print is not static.

146
00:09:50,220 --> 00:09:55,320
I don't want to determine what I'm printing here because I'm receiving something from the user and I

147
00:09:55,320 --> 00:09:57,520
want to print what the user gave me.

148
00:09:57,570 --> 00:10:04,390
So instead of using my quotation marks and defining you know this is all called static.

149
00:10:04,430 --> 00:10:04,820
All right.

150
00:10:04,830 --> 00:10:07,080
So once it's static it can't be changed again.

151
00:10:07,080 --> 00:10:15,360
So if I type hello world then Hillary will be printed if I type my name manually then obviously I am

152
00:10:15,390 --> 00:10:22,230
bypassing whatever was inserted through the console because anybody can come and use this program put

153
00:10:22,230 --> 00:10:28,720
in that name and this will always just print tor Williams regardless of what values inside name.

154
00:10:28,890 --> 00:10:36,120
So what we want to do is print the value inside of name to the screen and the way that is done is to

155
00:10:36,120 --> 00:10:38,630
actually put the variable names.

156
00:10:38,640 --> 00:10:44,460
So console the right line and then we put in the variable and notice once again we need a string value

157
00:10:44,700 --> 00:10:47,550
but we do have a string variable.

158
00:10:47,550 --> 00:10:49,440
So there are two ways to get the string.

159
00:10:49,440 --> 00:10:55,170
We can use it as static meaning whatever at Whittier will never change until I come back in the code

160
00:10:55,200 --> 00:10:59,790
and change it or I can use a variable of type String.

161
00:11:00,660 --> 00:11:00,920
All right.

162
00:11:00,930 --> 00:11:07,650
So I just declared a variable of type String received some string input from some user and went to print

163
00:11:07,650 --> 00:11:08,880
it back to the screen.

164
00:11:09,180 --> 00:11:15,570
So once again every line ends with a semicolon a CDO studious I mean semicolon is expected.

165
00:11:15,570 --> 00:11:24,090
So I put that there and then I just run no notice that the start still has the hello world.

166
00:11:24,090 --> 00:11:28,940
So if I were only still just going to print Hello world it's just going to execute the hello world program

167
00:11:29,370 --> 00:11:35,160
we have multiple projects and at this point I want to run input output and not hello world.

168
00:11:35,160 --> 00:11:41,750
So what I need to do is change the startup project from hell world to input output.

169
00:11:41,760 --> 00:11:50,210
So I want to right click input output and then select the the option that is set start set.

170
00:11:50,250 --> 00:11:52,900
Start a project so I click that.

171
00:11:53,430 --> 00:11:55,750
And then notice that this is no bull.

172
00:11:55,770 --> 00:11:58,790
So before hello or loss board No this one is bull.

173
00:11:58,800 --> 00:12:03,850
So that's a nice quick way to know which one is a startup project and the notice that contextually the

174
00:12:03,870 --> 00:12:08,260
start button text also changed so I can just click input output.

175
00:12:08,340 --> 00:12:16,390
So my program is started and it's just going to sit there with a blank screen just blinking and waiting.

176
00:12:16,410 --> 00:12:20,220
So what it is doing is waiting on the redesign.

177
00:12:20,250 --> 00:12:21,990
So it already declared name.

178
00:12:21,990 --> 00:12:25,200
You're not going to see a visual cue of the variable being declared.

179
00:12:25,200 --> 00:12:27,900
You're going to forever read line.

180
00:12:27,900 --> 00:12:32,430
It's just going to wait until there is some input followed by an enter key.

181
00:12:32,610 --> 00:12:43,210
So if I put me with a fictitious name Archibald Gordon and then I press enter then it executes A.C.

182
00:12:43,260 --> 00:12:46,190
Archibald Gordon printing about the screen.

183
00:12:46,190 --> 00:12:51,570
No this is not very intuitive because it was just blank you were just waiting what exactly was it waiting

184
00:12:51,570 --> 00:12:51,930
for.

185
00:12:51,930 --> 00:12:57,510
So it's always good to give your user a visual cue to say Please enter your name or something like that

186
00:12:57,530 --> 00:12:57,810
right.

187
00:12:58,200 --> 00:13:06,420
So what I'm going to do is above this line where I am receiving data I'm going to put a console right

188
00:13:06,450 --> 00:13:08,600
line to print to screen the prompt.

189
00:13:08,610 --> 00:13:12,150
So we've got this up prompt so console Dot.

190
00:13:12,320 --> 00:13:12,690
Right.

191
00:13:12,700 --> 00:13:16,770
Line open braces are open parentheses.

192
00:13:16,770 --> 00:13:27,020
And then I want the static text that sees enter your name so I'm saying please I can say Please enter

193
00:13:27,030 --> 00:13:28,820
and name can whatever your prompt is.

194
00:13:28,820 --> 00:13:33,830
So obviously whenever you run a program or you use a program when you're filling out a farm on the Internet

195
00:13:33,830 --> 00:13:35,550
whatever it is you're doing on a computer.

196
00:13:35,630 --> 00:13:39,980
They always give you a visual cue to say this is the data I'm expecting to from you right.

197
00:13:39,980 --> 00:13:40,740
No.

198
00:13:40,850 --> 00:13:45,140
So I'm seeing enter your name and then this line needs to be for the best in the colon.

199
00:13:45,290 --> 00:13:48,770
And then I'm going to wait for you to enter your name.

200
00:13:48,830 --> 00:13:53,000
And then once you have done that I'm going to print your name back to the screen.

201
00:13:53,020 --> 00:13:56,020
So let's try that again all right.

202
00:13:56,020 --> 00:14:00,140
So no it says enter your name because it ran that consular line.

203
00:14:00,220 --> 00:14:01,330
Enter your name.

204
00:14:01,330 --> 00:14:07,790
I know it's waiting for me to enter some value so that again storage inside my variable and then printed

205
00:14:07,840 --> 00:14:08,920
back to screen.

206
00:14:08,920 --> 00:14:16,980
So this time I'm going to use Q Early figure in and then I'm going to press enter and then you notice

207
00:14:16,980 --> 00:14:17,850
it printed.

208
00:14:17,970 --> 00:14:19,790
Kimberly Fagan back to screen.

209
00:14:19,800 --> 00:14:25,060
So no it's still not very intuitive because I don't know which one is which.

210
00:14:25,110 --> 00:14:26,640
Okay I'm looking at a console.

211
00:14:26,640 --> 00:14:31,980
I see Kimberly figure and I just see repeated what what is the repetition for it's not very intuitive.

212
00:14:31,980 --> 00:14:37,050
They always want to put in visual cues to use us so that they know exactly what they're looking at at

213
00:14:37,050 --> 00:14:38,030
each point.

214
00:14:38,040 --> 00:14:45,480
So I'm just going to close this console and then all I'm going to do is putting on the console or Atlanta

215
00:14:45,480 --> 00:14:50,730
or put in more text in this console or line to make sure that contextually you know exactly what you're

216
00:14:50,730 --> 00:14:51,330
looking at.

217
00:14:51,810 --> 00:14:57,920
So what I'm going to do is add another console right line and then this I actually go into the console

218
00:14:57,960 --> 00:14:58,620
right.

219
00:14:58,620 --> 00:15:04,210
So the console dot I have a right line but you also have a right somewhat into our right.

220
00:15:04,230 --> 00:15:12,570
And really the difference between the right and the right line so right is going to see your name is

221
00:15:13,530 --> 00:15:19,230
and then semicolon and then we're writing once again.

222
00:15:19,230 --> 00:15:22,900
So the console the name that was entered.

223
00:15:22,920 --> 00:15:25,550
So let's try that again.

224
00:15:25,560 --> 00:15:27,570
All right so now we see it enter your name.

225
00:15:27,570 --> 00:15:38,690
So OK this time it is Paul Bishop and then we press enter and then we see your name is colon Paul Bishop.

226
00:15:38,720 --> 00:15:47,810
No notice that when we did console right line it automatically went to the next line and waited for

227
00:15:48,020 --> 00:15:51,170
text when we did console a dot right.

228
00:15:51,170 --> 00:15:56,870
It just did it in one line and then whatever as we wanted it stood in that line.

229
00:15:56,900 --> 00:15:59,010
So that's the difference between right and the right line right.

230
00:15:59,030 --> 00:16:03,830
Line automatically it's almost like you type a sentence in Microsoft Word and you press enter and go

231
00:16:03,830 --> 00:16:04,640
to the next line.

232
00:16:04,640 --> 00:16:09,980
That's what right line does for you automatically it just puts the next block of text in the next line

233
00:16:10,010 --> 00:16:10,910
automatically.

234
00:16:11,090 --> 00:16:16,280
However right will not meet that break it will just any other string that is to be printed will just

235
00:16:16,280 --> 00:16:19,410
be printed in the same line onto that line.

236
00:16:19,510 --> 00:16:22,100
You know it's the text wraps.

237
00:16:22,200 --> 00:16:24,040
You know we all should know what word repping is.

238
00:16:24,050 --> 00:16:26,850
So onto the takes the reps are on the screen.

239
00:16:26,900 --> 00:16:28,070
That's all right.

240
00:16:28,070 --> 00:16:28,480
Works.

241
00:16:28,480 --> 00:16:33,050
So that's the difference between console dot right and the console dot right line.

242
00:16:33,110 --> 00:16:34,970
So that's it for input output.

243
00:16:35,000 --> 00:16:38,750
So let's us do a quick review one we learn to declaring variables.

244
00:16:38,750 --> 00:16:42,100
Once again there are many data types that variables can have.

245
00:16:42,110 --> 00:16:44,230
We're just keeping it simple we're just getting started.

246
00:16:44,230 --> 00:16:53,090
So I'm just using string where I collect some text and store inside some variable called name then I

247
00:16:53,090 --> 00:16:57,430
prompt the user for them to enter their name and then once they enter it.

248
00:16:57,440 --> 00:16:59,990
So this is all we get input from the console.

249
00:16:59,990 --> 00:17:07,960
We automatically assign it to our variable having gotten and stored that value from the user.

250
00:17:07,970 --> 00:17:10,510
We then proceed to see your name is.

251
00:17:10,510 --> 00:17:16,610
So we're printing back some static sentence that's giving them a visual cue as to what the data is that

252
00:17:16,610 --> 00:17:17,300
we're printing.

253
00:17:17,300 --> 00:17:19,720
So we're seeing your name is colon.

254
00:17:19,730 --> 00:17:21,200
This takes will never change on this.

255
00:17:21,200 --> 00:17:28,580
I change it in the program but then we dynamically printed whatever name was entered because we printing

256
00:17:28,580 --> 00:17:35,300
by the value in the variable in the next lesson we're going to go through some more data types in C

257
00:17:35,300 --> 00:17:42,290
sharp and look at the requirements between collecting data from the console for these different data

258
00:17:42,290 --> 00:17:46,270
types and printing them back and what conversions need to be done.
