تدريب Shadowing: How to Get Started with C# in Visual Studio Code! Full Tutorial for Beginners - تعلم التحدث بالإنجليزية عبر الفيديو

جارٍ التحميل...
1
What's going on guys, welcome back to the channel
2
and today's video is going to be an absolute beginner crash course in C Sharp.
3
So to get started with C Sharp you're going to want to install an IDE, an integrated development environment, and the one I'll be using for this tutorial series
4
and I really recommend this one is Microsoft Visual Studio.
5
To get to it, just Google Visual Studio download, take the link that will take you to Microsoft.com.
6
And for this installation, you can either download Visual Studio, make sure you grab Community Edition so you don't have to pay for it,
7
it's totally free, or you can just hit this download Visual Studio with .NET.
8
If you do do the community download, then there's going to be a whole bunch of options
9
and you have to select some things to make sure you get the right type.
10
After you download Visual Studio, it's going to ask you what kind of install you want, and just make sure you select the one that says .NET Framework, because that's what we'll be using for C Sharp.
11
So once you have it downloaded and installed, you're going to click on Visual Studio to get to open, and just create a new project.
12
It gives you all these options, because Visual Studio has like 100 gigabytes worth of plugins and different applications you can run through it.
13
But what we're going to be using is console app with .NET framework.
14
So there are so many options that there's actually even two called console application.
15
So make sure you grab the one with .NET framework so that you can follow along in this tutorial.
16
So hit next, give it a name, we'll call this C sharp crash course, call it whatever you want, and just hit create.
17
And what you're going to notice once it loads up is there's a little bit of pre-populated code.
18
And you're going to see it says using system and then a whole bunch of add-ins after that.
19
Don't worry about these too much.
20
They're essentially modules accessing things inside of your computer so that the code can run.
21
Just leave it as is.
22
It needs to be there, but you don't really need to know what it means for this tutorial.
23
And then kind of the same with this solution explorer over on the right.
24
There's a whole bunch of things in there, properties, references.
25
As we get more into C-sharp, we'll talk about what a lot of those do, but all you really need to recognize for today is this
26
C-sharp file is given the same name you just gave your project, and you'll notice over here on the left your namespace is also the name of the project you just gave it.
27
And this auto-populated class is really just a location to put functional code inside of it.
28
We'll really nail down a description as we get more into the tutorials, but I just want to get you guys programming as fast as possible.
29
And then this static void main is a method and a function where you're going to put code as well.
30
But all you really need to know for now is every time there's an open and closed curly brackets, that's essentially the start of and end of a code module.
31
And for getting started, you want to just put all of the functional code inside of your main function.
32
You'll notice the indentation is going to be pretty much automatic for you, so you don't have to worry about syntax,
33
just make sure it's inside the curly brackets underneath static void main
34
and we'll write all of our code for this tutorial inside of main.
35
So the very first thing I want to do is just get something displayed on the console.
36
If this is the first programming language that you've ever seen and somehow the first tutorial that you've ever watched,
37
welcome and be sure to like and subscribe for more content, but you're probably familiar with the fact the first program
38
that people always write is basically a Hello World program where they just print Hello World onto the screen.
39
That's kind of boring, so instead of writing Hello World, we'll write like, what is freaking up?
40
Because that's way cooler.
41
But I want to talk about this line of code because there's a few things going on here, C-sharp specific, that we should really discuss.
42
So console is how you address the window that's going to pop up.
43
The console is sort of referred to as like the command window.
44
If you're completely unfamiliar with computers, a console window is basically the lowest level, just simple display that you can get out of your computer.
45
There's not a lot going on.
46
It's black and white typically.
47
It's just plain text.
48
And so console.writeLine is all you need to put in to get something to display on a window
49
when you run your program.
50
But what you'll see, so console.writeline, and then open parentheses, close parentheses,
51
and then any text that you put inside of quotation marks is going to display on the screen.
52
And then make sure anytime you have a line, so this is basically like a little executable, it's an instruction.
53
Anytime you want to end an instruction, you need to make sure you put a semicolon at the end of the line.
54
You're going to get errors if you don't put those in.
55
C Sharp in Visual Studio is pretty good about helping you debug and troubleshoot errors.
56
So if you forget a semicolon, a lot of the times you'll get a little error pop-up that says like semicolon expected.
57
You're going to forget about semicolons.
58
People who have been programming for years forget semicolons.
59
So don't worry about it.
60
Just try to keep that in mind.
61
But so this is all we need to display something on the screen.
62
But what you'll see if I go up here and I hit start and it's going to do something called compiling, which is making sure your code is valid.
63
And then it's going to run.
64
But what you saw there, maybe you didn't, the console pops up just for like one scan of the computer.
65
And then it goes away right away because it's executing the code.
66
And then as far as it can tell, it's done.
67
So what we need to do is just put kind of a break in this code by adding console.readline, and then we'll just do open and close parentheses, and then a semicolon.
68
And now when we run this, I'll talk a little bit about what that does.
69
Okay, we get our text.
70
What is freaking up?
71
That's sweet.
72
So that's cool.
73
That's basically our Hello World program.
74
And what it's doing right now, you can see the blinking inside of our console window.
75
It's waiting for some sort of text.
76
So I type whatever in here and then when I hit enter, it's going to execute and then read that line and that's
77
when the window closes So we use this read line to add a break to the programming, but this is super useful
78
Anytime you want to slow down a program and understand where it is at the moment
79
You just hit you put a console dot read line in there and that'll put a break in your programming Okay, so that's sweet.
80
That's your first function you've downloaded Visual Studio and gotten programming in like five minutes.
81
So great job.
82
Let's go to the next thing.
83
Let's start doing something kind of cool.
84
A lot of tutorials will stop right there and be like, oh, you learned Visual Studio.
85
Like, you learned C sharp.
86
Let's actually do something useful.
87
So I want to talk real quick.
88
I'm going to copy this console write line and we're going to change the text.
89
But I want to talk a little bit about the order it goes in.
90
So I'm going to put like three different fruits in here so that you can see apple, banana, and then orange.
91
So hopefully if you're familiar with English and how we read in society,
92
we go left to right and top to bottom and that's how C sharp executes as well.
93
So if I run this, you'll see apple first, banana second, orange third.
94
So order matters.
95
And what I mean by that is like
96
if I'm to gonna copy orange and move it up to the top
97
and then I run this you're gonna see orange before apple
98
and banana now so this order is is also how it's going to execute so
99
if you ever write code where like something happening down here
100
needs to see something has completed up here order is really important it's going to give you an error
101
if you try to like reference a variable that doesn't get created until later in your program.
102
That's kind of a universal truth of programming.
103
So even if you learn other languages, if you learn Python, it's exactly the same Java.
104
It doesn't matter if you try to reference a variable on a line before you have instantiated,
105
called, defined, whatever the verbiage of that language is.
106
If you haven't created a variable, you're not going to be able to use it yet.
107
So that's cool.
108
We've written multiple lines of code.
109
We've got a break in there so that we can read about it.
110
But let's start using variables.
111
I just referenced variables, just talking about them, and that's a super important thing in all programming, especially C-sharp.
112
To use variables is going to give you some flexibility.
113
So let's say you wanted to create a little Mad Libs.
114
That's your name is Pete, your
115
age is 25 and then we'll say third line
116
but next year you will be 26 okay like yeah I can enter these manually
117
but that's not a very robust program what would be a lot better is
118
if I had a variable for my name
119
so we'll make to make a variable you enter the data type
120
and we'll talk a little bit about data types in a second
121
but name is going to be a string
122
so you type in the word string
123
and then you type the name the name of your variable which in this case is going to be name
124
and then you give it an initial value
125
so for a string we'll say name is going to be equal to pete
126
and make sure you've got your semicolon and then we will say for age
127
but age is going to be a whole number.
128
So that's integer, which is just int in C sharp.
129
And then we'll say age, and that's equal to, and you don't need quotations when you're doing integers, it's going to recognize the number format.
130
Okay.
131
So now, instead of your name is Pete, we're going to say your name is space.
132
And then we're going to use this plus sign, which is, it's technically addition, but in string terms, this is called concatenation.
133
And so we're basically saying your name is plus and then the name of the variable we gave it.
134
So we don't have to type in the whole string name equal Pete.
135
We just say name.
136
And then it's the exact same thing for age.
137
And this is one difference between like Python and C sharp and C plus plus.
138
In C sharp, it can concatenate a string with a integer or decimal value just by it's able to convert that.
139
It's able to handle that internally.
140
If this was Python, you'd have to do a string conversion so that you're only dealing with strings.
141
You can leave this in here just as an integer.
142
But then, this is a super cool thing.
143
Now, in the middle of our program, we can just say age equals the previous value of age plus one.
144
And now we can say right here, next year you will be plus age.
145
And this is going to do basically exactly what we need it to do.
146
It's always going to give you the value and CIR I forgot semicolon.
147
This is always going to give you a value saying next year you will be your age plus one.
148
And you could make this a new variable.
149
You could say like new age equals age plus one.
150
You'd have to do the whole gambit just like this.
151
But because order matters, we can have it work both ways.
152
We can just say age equals age plus one.
153
And so this is going to tell us we're 25
154
and then it's going to add one to it and then next year you'll be 26.
155
So if I go ahead and run this and you run yours, you're going to see your name is Pete, your age is 25, next year you'll be 26.
156
Okay, let's do someone else.
157
Let's say your name is Jack and you're 27.
158
Okay, so all I did was change two values and right away the whole thing updates to be correct.
159
Your name's Jack, 27, next year will be 28.
160
So that's the power of variables, and this is kind of a silly example because there's not really a value in Mad Libs,
161
but in general, anytime you store value in a variable, it's because you want to keep using it, you want to manipulate it throughout your program,
162
and it's a lot easier to store that somewhere than have to keep in mind what it was and hard code it. So that's super useful.
163
That's kind of a brief introduction to variables.
164
But let's say we want this to be a little more intuitive.
165
And I don't want to have to change these values initially.
166
I want to ask the user for input.
167
Because right now, all we're really doing is providing output to the system.
168
what we're going to do is make it where we ask the user for that name and for that age.
169
And this is going to be great because essentially the core of programming is get user input,
170
process the input, and then display some output using the inputs that you got.
171
So we're going to do all of that inside this function in just a few minutes.
172
So instead of just doing this string name equals and then just entering a value,
173
what we're going to do is give them some instructions.
174
So we'll use this console.writeLine and we'll say, parentheses, enter your name.
175
And we'll put that on one line.
176
And then we'll go ahead and close that semicolon.
177
And now what we're going to do is we're going to use, and you've actually already seen the console.readLine function because we've used it before.
178
Make sure you get your indentations correct
179
but what we do here is we say string name equals
180
and instead of giving it an initial value what we're gonna do is use console dot read line okay
181
so this is really cool now we're gonna say enter your name
182
and then the little blinker the on the you know thing
183
signifying your entering text is just gonna sit there until the user types in their name
184
and hits enter and we're going to take whatever the user entered
185
and we're going to store it in a variable called name that we'll then use later on.
186
So this is an important point here.
187
Read line is always going to take whatever was written in as a string.
188
So if the next thing we want to do, I'm going to go ahead and copy this but we're going to change it to age.
189
So write line enter your, and this time we will say age.
190
Now, it's still going to be int age equals, but we can't just take console.readline.
191
I wish we could, but we have to convert it to an integer because it's coming in as a string.
192
And that's why you're going to get like a red squiggly line if you just leave it like this, because it's telling you it can't just implicitly convert string to integer.
193
It has to be told to convert it.
194
Fortunately, that's a super easy function in C sharp.
195
You just use convert dot and then this in particular we're going to an integer.
196
And so the function is to int 32.
197
It's 32 because of how many booleans technically and binary that are used in an integer value.
198
You don't have to worry about that.
199
You just have to know it's to int 32.
200
And then put that console dot read line, that whole block of code, put it inside its own set of parentheses.
201
And now the user is not going to notice any difference between entering their name and entering their age.
202
It's just the code now knows to handle that as an integer, and then everything else is going to work just fine.
203
So let's go ahead and run this.
204
Let's say enter your name.
205
Let's do Pete.
206
Enter your age, 25.
207
Your name is Pete.
208
Your age is 25.
209
Next year you'll be 26.
210
Let's go ahead and close it.
211
Let's run it again give it some different values.
212
We're Jack, we're 27.
213
Your name's Jack, you're 27, next year you'll be 28 so just like
214
that we've created our first program our first function our first variables everything inside of 15 minutes
215
and hopefully you understand where all this code is coming from
216
i know we haven't covered some of the concepts of like structure of the project structure of the file
217
but you're already able to pull a variety of information in from users manipulate it inside of your program, and then output data based on what you got.
218
So this is a crazy useful speed tutorial.
219
You learn a lot of concepts right here in 15 minutes.
220
I'll touch on one more thing before we end this initial tutorial, because you've seen integers and you've seen strings,
221
and we didn't really talk a ton about them.
222
We basically just said integers are whole numbers, like an age, and string is any combination of text.
223
But let's just talk briefly about two things.
224
So first, adding comments to code in Python, I just used forward slashes,
225
but you do two backslashes and you can type whatever you want after that.
226
Two forward slashes is going to mean whatever else is on that rung, on that line of code, isn't going to get executed.
227
They're just notes for the programmer.
228
They live inside of the function.
229
So everything I'm about to put underneath here is just for our data type discussion.
230
It's not really useful code, but this is how you do comments, okay?
231
So that's a super useful general piece about C Sharp you should know.
232
And we've already seen that integers are basically any whole number, like 100 or 120.
233
We've already seen that strings are basically any text text.
234
So you could have names or I don't know other text or other things.
235
Okay, but those are probably the two most common ones you'll see.
236
But a few others that really pop up a lot in programming are a double.
237
So I'll talk briefly about there's a variety of ways to have decimal point values,
238
and they could be in double, float, or what's called decimal format.
239
And I'm not going to go too into each of them, just know that it kind of is like how precise do you need it.
240
Float, technically speaking, is the least precise.
241
Decimal is technically the most, I believe, but just in general, I always use double for decimal points.
242
So basically if you have a number like money, like you want to be really accurate with money.
243
So someone owes you $345.35.
244
I would always put that in a double.
245
Okay, that's just another really common variable.
246
One that maybe you're not used to if you don't do a lot of programming or you haven't in the past
247
is what's considered a Boolean.
248
But if you think of all the scenarios in code where you have an on-off
249
or a true-false yes-no type scenario where you're just checking if something is or is not active.
250
This is also sometimes called discrete points or digital points.
251
Those are just all different names for it.
252
But the variable type that you're going to use, the data type, is Boolean.
253
And so Boolean, which I'll say is going to be true-false, can only have two values,
254
true like that or false like that.
255
And it's a super useful thing in coding.
256
it's way easier than creating an integer
257
and then checking every time you want to reference it
258
if it's equal to a zero or a one or something like
259
that or a string and checking if it's equal to the text true
260
or the text false just use this type of variable it's super critical in programming
261
and you're really going to want to get familiar with booleans
262
one more that's a little bit less common is a character
263
and so this is like a single letter or a single number
264
that you wanted to put into a variable of exactly space one, but it could be a varying character.
265
So you could think of like a grade, like A, B, C, D, F in the grade system,
266
and you actually use single quotations for these ones.
267
So you could put an A here, it could be lower, it could be upper, it could be a number,
268
but a character is only going to be able to house one character, and if you put multiple in, it's going to give you an error.
269
So that's character.
270
You won't see that one as much, but it is nice to know that it's out there.
271
There are some other data types that will probably crop up as we do more and more of these tutorials.
272
But for now, those are the most common ones that are going to pop up in your tutorials, in your programs.
273
But in general, this is really a 20 minute crash course
274
that should give you a ton of concepts that are going to get used in C Sharp all the time.
275
I hope you found it useful.
276
If you did, please consider subscribing to the channel, liking the video.
277
Helps me out a ton.
278
If there's something specific you want to see in a future video, be sure to let me know about in the comments below.
279
I'll get back to you as soon as possible, and it might even make that concept into a video.
280
So thank you so much for your support, good luck with your code, and thanks for watching.
281
Thanks, bye.

حول هذا الدرس

أنت تتدرب على اللغة الإنجليزية باستخدام "How to Get Started with C# in Visual Studio Code! Full Tutorial for Beginners" مع تقنية الـ Shadowing.

ما هي تقنية التظليل الصوتي؟

التظليل الصوتي (Shadowing) تقنية تعلم لغة مدعومة علمياً، طُورت أصلاً لتدريب المترجمين الفوريين المحترفين. الطريقة بسيطة لكنها قوية: تستمع لصوت إنجليزي أصلي وتكرره فوراً بصوت عالٍ — كظل يتبع المتحدث بتأخير 1-2 ثانية. تُظهر الأبحاث تحسناً كبيراً في دقة النطق والتنغيم والإيقاع وربط الأصوات والاستماع والطلاقة.