Knowby
C 2 hello world
Hey everybody, it's Brian and welcome to our second C# tutorial. Go ahead and go File > New Project and then just choose Console Application.z
Hey everybody, it's Brian and welcome to our second C# tutorial. Go ahead and go File > New Project and then just choose Console Application.z
1
Step 1 of 53
2
Step 2 of 53

Ccfffggv

  • Me encanta

  • Disks

  • Dkdkdkd

  • Dkdkkd

3
Step 3 of 53
Hey everybody, it's Brian and welcome to our second C# tutorial. Go ahead and go File > New Project and then just choose Console Application.
4
Step 4 of 53
We're going to make the obligatory Hello World program.
5
Step 5 of 53
Whenever you learn a new language first thing they want you to do is write a Hello World.
6
Step 6 of 53
Now you may see me typing and you're probably wondering how is he typing so fast? See, when you start typing that little window pops up.
7
Step 7 of 53
That's called IntelliSense. You can just either double click on Console or you can select it and press Tab and it will write it out for you.
8
Step 8 of 53
When you press dot it brings up the properties for that object. So we're just going to type read.
9
Step 9 of 53
All we've added are two lines to our Console Application. Write Line, Hello World and Read.
10
Step 10 of 53
Let's go ahead and press Ctrl+S to save. I'm sorry, Save As.
11
Step 11 of 53
We're just going to call this CS02. Let's put this in whatever location you're going to be saving your projects.
12
Step 12 of 53
Make sure you're all nice and save there.
13
Step 13 of 53
Let's run this and see what happens.
14
Step 14 of 53
You notice there it says Hello World. Well, we flew through that very quickly so how did we get to that step? Well, first thing when it creates our Console Application it adds all these using.
15
Step 15 of 53
Now what is this? These are things that we're importing into our program. There's a lot of stuff going on under the hood that we didn't write.
16
Step 16 of 53
Microsoft wrote it for us. For example, System. System.Collections.Generic.
17
Step 17 of 53
Systems.Link. Systems.Text. I don't expect you know what any of that stuff is. You'll learn this in future tutorials just for the time being.
18
Step 18 of 53
Kind of click the I believe button and believe that we are importing things.
19
Step 19 of 53
Now, think of a namespace, Console Application 1. Think of a namespace like an apartment.
20
Step 20 of 53
The trick with these namespaces is there can only be one of a specific type in there. For example, we have this program.
21
Step 21 of 53
There can only be one program in this namespace.
22
Step 22 of 53
Don't get hung up on the word program. This could be Fuzzy Bunny Slippers or Bob. We're just going to call it Bob for the time being.
23
Step 23 of 53
There can be only one Bob in your namespace. Now, you can have a different namespace.
24
Step 24 of 53
For example, Console Application 2 or I Hate Fuzzy Bunny Slippers or whatever that can contain a Bob.
25
Step 25 of 53
But this namespace can only contain one Bob. In this case, we're calling it Program.
26
Step 26 of 53
Now, a class. Class is a blueprint. Everything in .NET is an object.
27
Step 27 of 53
In order for it to be an object, it needs a blueprint, which is called a class.
28
Step 28 of 53
So say it with me. Everything in .NET is an object. That means everything in .
29
Step 29 of 53
NET is a class. Or I should say it derives from a class.
30
Step 30 of 53
Then we have this ugly-looking static void main, strings, args. What is this thing? Well, that's the main entry point of your application.
31
Step 31 of 53
Static simply means there can be only one. Void means it simply returns nothing.
32
Step 32 of 53
Main is the main entry point. These are arguments. You can actually pass arguments into your program.
33
Step 33 of 53
You see these squiggly little blocks? C# is actually a C-style language, which means it uses these blocks.
34
Step 34 of 53
You notice how there's some here, some here? Well, these are called code blocks.
35
Step 35 of 53
For example, that's the namespace code block. And this is the class code block.
36
Step 36 of 53
And this is a function code block. And what that does is it determines the scope and the order of execution, things it will cover in future tutorials.
37
Step 37 of 53
For now, all you really need to understand is that you're importing things.
38
Step 38 of 53
You have a namespace. You have a blueprint. You have a starting point.
39
Step 39 of 53
And then you can manipulate the console using WriteLine and Read.
40
Step 40 of 53
And we're using Read simply because if you... Let's comment that out.
41
Step 41 of 53
Notice the double slashes? That comments it out, meaning this will not execute.
42
Step 42 of 53
It's the same thing as if it didn't exist at all.
43
Step 43 of 53
Run this. You notice how the window just appears and disappears almost instantly? That's because the program finished.
44
Step 44 of 53
It didn't have anything left to do. So we're going to say console read just to keep that window open when we run this.
45
Step 45 of 53
That's all for now. If you like this tutorial, there are many more out on my website.
46
Step 46 of 53
And let me pull it up here real quick. www.voidrealms.
47
Step 47 of 53
com. Just click tutorials. And I've kind of got it categorized. Everything will be under C#.
48
Step 48 of 53
There's really nothing there because I haven't uploaded the videos yet. So I'll just choose Visual Basic and just kind of click like a hello world.
49
Step 49 of 53
And you can see how there's download the source code. So I try to upload the source code for every tutorial.
50
Step 50 of 53
And you can actually watch the YouTube video in the website. No, there's no banner ads or cheesy gimmicks or anything like that.
51
Step 51 of 53
If you do go to download the source code though, it will say, "Please donate." I don't expect you guys to donate.
52
Step 52 of 53
That's more for businesses that are using this to teach their employees and things of that nature.
53
Step 53 of 53
So go ahead. Go out to the website. Let me know what you think. Anyways, I gotta get going, this is Brian, thanks for watching.