Chapter 2. C# Basics
Now that you understand a little more about what C# can do, you will want to learn how to use it. This chapter on the basics of C# gives you a good start in that direction by providing you with a basic knowledge of the fundamentals of C# programming, which we build on in subsequent chapters. The main topics we cover 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()
methodBasic command-line C# compiler options
Using
System.Console
to perform console I/OUsing documentation features in C# and Visual Studio .NET
C# identifiers and keywords
Recommended 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 the following chapters.
Before We Start
As already mentioned, C# is an object-oriented language. As we get you up to speed in the fundamentals of the C# language, we will be assuming that you have a good grasp of the concepts behind object-oriented (OO) programming. In other words, we will expect you to 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, plenty ...
Get Professional C# 2005 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.