Professional C# 4 and .NET 4
by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner
Chapter 2. Core C#
WHAT'S IN THIS CHAPTER?
Declaring variables
Initialization and scope of variables
Predefined C# data types
Dictating the flow of execution within a C# program using conditional statements, loops, and jump statements
Enumerations
Namespaces
The
Main()methodBasic command-line C# compiler options
Using
System.Consoleto perform console I/OUsing internal comments and documentation features
Preprocessor directives
Guidelines and conventions for good programming in C#
Now that you understand more about what C# can do, you will want to learn how to use it. This chapter gives you a good start in that direction by providing you with a basic knowledge of the fundamentals of C# programming, which is built on in subsequent chapters. By the end of this chapter, you will know enough C# to write simple programs (though without using inheritance or other object-oriented features, which are covered in later chapters).
YOUR FIRST C# PROGRAM
Let's start by compiling and running the simplest possible C# program — a simple console app consisting of a class that writes a message to the screen.
Note
Later chapters present a number of code samples. The most common technique for writing C# programs is to use Visual Studio 2010 to generate a basic project and add your own code to it. However, because the aim of Part I is to teach the C# language, we are going to keep things simple and avoid relying on Visual Studio 2010 until Chapter 16, "Visual Studio 2010." Instead, we will present the code as simple ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access