Hello everyone, hope you all are fine and having fun with your lives. Today, I am going to share the First Code designed in C# tutorials. In the previous tutorial, we have seen an Introduction to C#, in which we have seen How to create a new project in C#. Now if you haven’t read it already then must read that one first as I am gonna take that one forward.
In Introduction to C#, we have created a new project in C# but we haven’t added any code into it as it was just the basic C# tutorials and today, I will first explain the code which was already in that project and then we will add some more code into it. So, let’s get started with our first code in C# Tutorial series.
First Code in C# Tutorial
- In the last tutorial, we have created a project which looks something as shown in the below figure:
- If you have a look at the abve figure or the project you created then you can see its divided into three portions.
- The right most portion is Solution Explorer, which contains all the files of your project, as shown in below figure:
- The highlighted file in the above figure is Program.cs which is the actual code file in which I am gonna write our first code in C# tutorial.
- In the properties we have AssemblyInfo.cs so double click this file and it will open up as shown in below figure:
- Now in this file you can see we can change the name of the project and can also add the copyrights etc.
- So, its like the settings file for the project.
- In the references folder we have different system files which are also essential for the project.
- So, now we have got the idea about the basic files of the project, now let’s design our first code in it.
- So, add the below code into the Main function of your Program.cs File:
- Now your Program.cs file will look something as shown in below figure:
- Now, we have designed our first code in C# tutorials, which should print Hello World on output console.
- In order to run this simulation you have to select Build and then Build MyFirstProject as shown in below figure:
- Now when you build your solution, after that you need to run your solution if you don’t get any errors.
- You will get the output as shown in below figure:
- Now when you press any key they console will stop.
- So, that’s how we can design our First code in C# tutorials.
That’s all for today. I hope you guys have got something out of it. In the coming C# tutorials, I will post more about C# and its concepts. So stay tuned and have fun !!! 🙂