Chapter 4. Language Syntax and Features

This chapter details the basic syntax, structure, and features of the C# language. We expect the reader to be familiar with the Java language, and we concentrate on C# features that are new or different.

General Program Structure

We begin with a simple program example to demonstrate the basic points that must be understood when writing C# code. The following Java code should be familiar:

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Contrast it with the following C# code:

using System;

public class Hello {
    public static void Main(String[] args) {
        Console.WriteLine("Hello World!");
    }
}

Although obvious similarities exist, the following points should be noted: ...

Get C# for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.