First Program in C#

This section provides a tutorial example on how to write the first C# program to print out 'Hello world!' on the screen, compile it and run it on with .NET Framework.

Let's follow the tradition of the programming language world and write our first C# program to print out "Hello world!" on the screen.

You can use notepad to write the following code and save it as Hello.cs:

class Hello {
   public static void Main() {
      System.Console.WriteLine("Hello world!"); 	

To compile and run the program, open a command window and issue the following commands:

C:\herong>set "NET=\windows\Microsoft.NET\Framework\v4.0.30319"

C:\herong>%NET%\csc Hello.cs
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

Hello world!

Congratulation, you have successfully created, compiled, and executed your first C# program!

Table of Contents

 About This Book

Introduction of C# (C Sharp)

 What Is C#?

 Installing .NET Framework 4.6.1 SDK

First Program in C#

 C# Program Structure

 Data Type and Variables

 Logical Expressions and Conditional Statements

 Arrays and Loop Statements

 Data Type Features

 Floating-Point Data Types

 Passing Parameters to Methods

 Execution Environment Class

 Visual C# 2010 Express Edition

 Class Features

 C# Compiler and Intermediate Language

 Compiling C# Source Code Files

 MSBuild - Microsoft Build Engine

 Memory Usages of Processes

 Multithreading in C#

 Async Feature from C# 5

 System.IO.FileInfo Class

 System.Diagnostics.FileVersionInfo Class

 WPF - Windows Presentation Foundation

 Partial Classes and Partial Methods

 Outdated Tutorials


 Full Version in PDF/ePUB