Chapter 2 - C# Basics | |
bySimon Robinsonet al. | |
Wrox Press 2002 | |
In this chapter, we have examined some of the basic syntax of C#, covering the areas needed to write simple C# programs. We have covered a lot of ground, but much of it will be instantly recognizable to developers who are familiar with any C-style language (or even JavaScript). Some of the topics we have covered include:
Variable scope and access levels
Declaring variables of various data types
Controlling the flow of execution within a C# program
Calling and declaring classes and methods
Working with arrays
C#'s operators
Converting data between different types
How the stack and heap are implemented by the CLR
Commenting code, and XML auto-documentation
We have seen that the syntax is similar to C++/Java syntax, although there are many minor differences. We have also seen that in many areas this syntax is combined with facilities to write code very quickly, for example high quality string handling facilities. C# also has a strongly defined type system, based on a distinction between value and reference types. Now we have a grounding in the C# language, we will move on to an in-depth look at C#'s object-oriented programming features in the next chapter.