Writing the first program in C#

  • Post category:C#
  • Reading time:2 mins read

C# is an object-oriented programming language and in C# program runs from top to bottom.

Program in C#

Let’s see a simple program in CS. I suggest using visual studio for writing C# code. In c# we create a file with extension .cs for example: program.cs

Console.WriteLine("Hello, World!");
Console.ReadLine();

Console.WriteLine(“Hello, World!”); prints the value written inside it and Console.ReadLine() work is to pause the execution of the code to get the input value from the user. You need to hit the enter button to continue the code execution if you are writing Console.ReadLine();

In C#, we write methods inside the classes. A single class contains different methods inside it. For example:

Class
Method1
Method2
Method3
Method4

Then, there are namespace in c#. We store the class in the related namespace. For example

namespace
class1
class2
class3
class4

Then, there are assemblies in c#. assemblies contain namespace. For example

Assemblies
namespace
namespace
namespace
namespace

 

Share this