Chapter 2
C# Basics
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. The main topics covered are:
- Declaring variables
- Initialization and scope of variables
- Predefined C# data types
- Dictating the flow of execution within a C# program using loops and conditional statements
- Enumerations
- Namespaces
- The Main() method
- Basic command-line C# compiler options
- Using System.Console to perform console I/O
- Using comments and documentation features
- Preprocessor directives
- Guidelines and conventions for good programming in C#
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.
Before We Start
As already mentioned, C# is an object-oriented language. Throughout this chapter and later chapters, we assume that you have a good grasp of the concepts behind object-oriented (OO) programming. In other words, we expect that you understand what we mean by classes, objects, interfaces, and inheritance. If you have programmed in C++ or Java before, you should have a pretty good grounding in object-oriented programming (OOP). However, if you do not have a background in OOP, you may find it helpful to familiarize yourself with OOP basics before continuing.
In this ...