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
- The Main () method
- Basic command-line C# compiler options
- Using System. Console to perform console I/O
- Using comments and documentation features
- Pre-processor 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, 01 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 chapter, we make many comparisons among C#, C++, Java, and Visual Basic 6 as we walk . through the basics of C#. If you are an experienced developer in these programs, you might prefer to read a comparison between C# and your selected language before reading this chapter. If so, we have also made available separate documents for download on the Wrox Press Web site (WWW. wrox . com) that give introductions to C# from the point of view of each of these languages.