Starting with C # in 3 steps

c sharpprogrammingtutorialtutorial

Written by:

Reading Time: 2 minutes

This post is to do the very common and popular “hello word” app. Thus it is a very simple and brief tutorial. I would do well to list all the main points in building a C sharp app albeit with this simple example.

We will be building console apps for a while until we go a little higher up the C sharp food chain. Hopefully a bulk of these console apps would be of some use to us.

In the previous post, we spoke on the reasons why it is necessary for you to know c sharp<link to post >. In this post we will continue by helping you build your first C sharp app.

What you need

The interest or enthusiasm

Tools you will use

  • Command prompt
  • Notepad

What we hope to achieve

Printing out the text hello world onto your console screen.

The steps

  1. Open notepad:

In notepad, copy and paste the following code.

using System;

namespace HelloWorldApplication{

class HelloWorld{

static void Main(string[] args){

//print hello world

Console.WriteLine("Hello World");





Do not worry we will go over these lines in a bit.

After pasting save the file.

Let’s save it as hello_c_sharp.cs

  1. Running our app:

Hit the key combination windows + R. this brings up the run window

Type in cmd. This opens up the command prompt window.

Navigate to the directory where you saved the file hello_c_sharp.cs.

Now type in the file name.

The text Hello World is printed on the screen.

  1. The end:

That it. Congratulations. You just built a C sharp app. That was quick, was it not?

Now let’s go over the lines of code.


The explanation

File extension:


CS file extension is how C sharp files are saved.


using System;

The word using means we want to import something else into our code and use it. In this case, it is System.  That is to say we are using the System classes as well as its methods. Console for example is one of its Classes.

The entry point to every c sharp app is via the main method.


namespace HelloWorldApplication

Together with the braces, it is used to group your code together. In the example, our code in a single block.


class HelloWorld

Classes enable bring structure to our code. As I mentioned from the previous post, C# is all Object Oriented Programming. This uses the concept of Classes a lot.

The method:

static void Main(string[] args)

As mentioned earlier, the style of OOP, makes use of classes, objects, and methods very heavily. In this scenario;

  • Static means this method cannot be created dynamically.
  • Void means it does not return another result. All the result ends up being worked out within the method.
  • Main is the name of the method
  • String[] args are the arguments being passes to the method.

Coincidentally, the main method is well, the main method for every C # application.

The comment:

//print hello world

Comments are lines that do not get executed. All they do is to provide descriptions, or notes so to what is being done, or ran.

So that ends my brief application on a simple C # application.  Thank you for your time. We will meetup again another week. Until then, keep learning.





Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up