C# Programming Structure | WaoFamHub



C# Programming Structure.

C# Programming Language


The lists of elements that are commonly used in a C# program are:

Library invoked by the keyword "using".
Declaring namespace using the "namespace" keyword.
Declaring a class using the keyword "class".
Class members and attributes.
The Main() method.
Other statements and expressions.
Writing comments for user understanding and non-executable statements.

Let's look into various parts of the above C# program.

/* Comments */

/* Print, some string in C# */, is the comment statement that does not get executed by the compiler and is used for code readers or programmers' understanding.

using

Here, using keyword is employed for fetching all the associated methods that are within the System namespace. Any C# program can have multiple using statements.

namespace

Next statement is used for declaring a namespace, which is a collection of classes under a single unit; here "printHelloCsharp".

Class

Next, you have declared a class "HelloCsharp" using the keyword class, which is used for preserving the concept of encapsulation.

main()

Inside a class, you can have multiple methods and declaring variable names. The static/void is a return value, which will be explained in a while.

Console.WriteLine()

Console.WriteLine() is a predefined method used for displaying any string or variable's value in a C# program.

Console.ReadKey()

Console.ReadKey() is another predefined method used to make the program wait for any key-press.


Post a Comment

Previous Post Next Post