Write Your First C Application

The C# (pronounced C sharp) language is a valuable asset in the .NET Framework. You can use C# to create standalone executables or to create dynamic content on a Web form.

If you are new to the C# language, you may want to start applying it by creating the simplest C# application possible. There are many types of applications that can be built with the C# language. Some of the more common ones that you can create are Windows applications, Web services, ASP.NET applications, and console applications. If you want the simplest application, a console application is a good choice.

Starting with the C# language, you can create a standard "Hello World" console application. To write your first application, you need a text editor, like Notepad, to generate the source code. The file type that typically holds C# code is a class file. A C# class is a text file saved as a *.cs file. You can compile this class with the C# compiler (csc.exe) at the command prompt which creates an executable (*.exe) file.

In C# applications, you can use Namespace aliases to easily leverage the .Net Framework classes. Namespace aliases are used to reference classes in the .NET Framework.

WRITE YOUR FIRST C# APPLICATION

WRITE YOUR FIRST C# APPLICATION

D Open your text editor.

Q Between the curly braces, type in the code to print out "Hello World using C#!".

D Open your text editor.

—0 Type using System; to import the System namespace and press Enter.

< Type the name of the class you want to create and press Enter.

—Q Type { }, placing the opening and closing curly braces on separate lines, to set off the body of the class.

S Between the curly braces, type static void Main() and press Enter to create the Main function.

-0 Type { }, placing the opening and closing curly braces on separate lines, to set off the body of the Main function.

Q Between the curly braces, type in the code to print out "Hello World using C#!".

Was this article helpful?

0 0

Post a comment