Join Alexander Zanfir for an in-depth discussion in this video A hello world application, part of Learning C#.
- [Instructor] We will quickly write a Hello World application just to get something functioning. Let's head over to file, new, project. From this list, let's select Console Application .NET Core. But before we continue, I'd like to cover the differences between traditional .NETs and .NET Core. .NET is a library that works with several languages. It was originally just for Microsoft platforms but with .NET Core, it became a multi-platform working on Windows, Linux, and Mac.
There's even a mono version of .NET called Xamarin which will also work on Android, iOS, and Windows Mobile to write applications for mobile platforms. Going forward, the most versatile and modern framework for C# is .NET Core. And this will be the primary focus of this course. Although majority of the features offered in .NET Core are also available on the traditional .NET framework. If you don't have much previous experience with .NET, please check out my C# with .NET course on the library to learn more about it.
Next, let's name our application. We'll call it Hello World. And then we'll hit okay. As we can see, the Visual Studio project template created a Hello World project for us already. We won't cover the code line by line in this video. Instead, we'll focus on a few key lines and commands you will need for the first challenge of this course. Starting with output. By outputting some text, to the console, then moving on to input, taking in some text from typing into the console. Let's begin.
We'll start just by running this program. We can start with the shortcut ctrl F5. This will compile the program and then run it. And as we can see, we're getting the Hello World output in the console that popped up. We can go ahead and close that. To run the program, we could've hit the play button at the top of the screen, or hit F5 instead, but this will run the program in debug mode. We will cover debugging later in the course, but for now, we will be using the non-debug mode so that we can execute things a bit quicker, and for that, we need to use ctrl F5.
Now, let's focus on line nine for a little bit. We can see that whatever we put into console.writeline as a string with double quotes wrapped around it, will get displayed on our console when we run the program. For a quick test, let's remove the exclamation mark and run our program again. We can see the changes have taken effect. And that's all I'd like to cover in this quick introduction. If you don't understand the rest of the lines on the screen, don't worry too much about it. We will cover everything we see here, and more, as we go through the course.
Now that we've covered outputs, let's take a look at input. But in order to save that input, we'll need to save it somewhere. So let's take a look at variables next.
Explore variables and data types; controlling program flow with conditions and loops; and building functions. Learn how to implement object-oriented programming such as encapsulation and inheritance in C#, and find out how to debug your code. Alexander then explores advanced concepts such as enumerators, ref parameters, interfaces, events, and abstract classes. In the last two chapters, he covers the "top" features introduced in the last several versions of C#, including lambda expressions and string interpolation.
- C# variables and data types
- Switch statements
- Object-oriented programming: encapsulation, properties, and inheritance
- Debugging C# code
- Advanced C# concepts
- Top new features