Introduction to C#
In this chapter, we will dive into the C# Programming Language and learn how it does the fundamental concepts of Programming. We will first look into the commonly used tools to create and execute a C# code. Once we have our tool setup, we will look into and see how we can do basic display, take user input, declare and use variables, operations, flow control and conditional statements in C#.
On this page
The C# Language ๐ป
C# (pronounced as โsee sharpโ) is a hybrid language in a sense that it is in between compiled and interpreted language. What it means is that, unlike traditional C++ and C which are both compiled into a machine code, C# codes are compiled into an intermediate language (IL) first that outputs an intermediate code which can then be compiled by โJust-In-Timeโ compilers into a machine code that can be understood by the machine. It is one of the most popular object-oriented programming languages that runs on top of .Net Framework. It has its roots in C, C++ and Java.
Microsoft has an entire documentation about C# that you can see ๐ here.
Tools of Trade ๐ง
For us to start learning C#, we need a tool we can use to create and execute a C# code. Here are some tools and applications that we can use:
-
Microsoft Visual Studio
The most common application or IDE (Integrated Development Environment) to use when creating a C# code is Visual Studio You can download Microsoft Visual Studio here in Microsoft’s official website - dotnet.microsoft.com/en-us/download.
Note that what is being downloaded there is the “Visual Studio Installer Manager”. Once this is installed on your machine, you can then use it to download and install the .Net component you want to use. To follow the C# fundamental examples that we have in this documentation, we need to install the ".NET Desktop Development" component.
Here’s the step-by-step guide on how to download and install Visual Studio in order to follow along with the examples on this documentation ๐ How to Install MS Visual Studio
-
Microsoft Visual Studio Code
Alternatively, Visual Studio Code or VS Code can be used in creating and running C#. Unlike Visual Studio, VS Code is not an IDE but rather a lightweight source code editor. While it doesn’t have the complete feature of an IDE, it relatively does the job well in creating C# applications (including the examples that we have in this documentation).
You can download Visual Studio Code on this site ๐ dotnet.microsoft.com/en-us/download. Make sure to also install the “C# Extension for VS Code” to create and run C# applications.
-
Source Code Editor (Notepad++) and .NET SDK
If installing an application like VS Code or Visual Studio is not possible on the specs of your machine, you may try using any text editor (in my example Notepad++, but you may try other source code editors) in writing and modifying your C# code and using dotnet CLI commands.
Here’s the step-by-step guide on how to use Notepad++ and dotnet CLI in creating and running C# code ๐ Create C# Console App using .NET CLI
๐ end of document ๐