Chapter 2. C Language Fundamentals

 < Day Day Up > 

Chapter 2. C# Language Fundamentals

Topics in This Chapter

  • Overview of a C# Program: In addition to the basic elements that comprise a C# program, a developer needs to be aware of other .NET features such as commenting options and recommended naming conventions.

  • Primitives: Primitives are the basic data types defined by the FCL to represent numbers, characters, and dates.

  • Operators: C# uses traditional operator syntax to perform arithmetic and conditional operations.

  • Program Flow Statements: Program flow can be controlled using if and switch statements for selection; and while, do, for, and foreach clauses for iteration.

  • String: The string class supports the expected string operations: concatenation, extracting substrings, searching for instances of a character pattern, and both case sensitive and insensitive comparisons.

  • Enums: An enumeration is a convenient way to assign descriptions that can be used to reference an underlying set of values.

  • Using Arrays: Single- or multi-dimensional arrays of any type can be created in C#. After an array is created, the System.Array class can be used to sort and copy the array.

  • Reference and Value Types: All types in .NET are either a value or reference type. It is important to understand the differences and how they can affect a program's performance.

In September 2000, an ECMA[1] (international standardization group for information and communication systems) task group was established to define a Microsoft proposed standard for the C# programming language. Its stated design goal was to produce "a simple, modern, general-purpose, object-oriented programming language." The result, defined in a standard known as ECMA-334, is a satisfyingly clean language with a syntax that resembles Java, and clearly borrows from C++ and C. It's a language designed to promote software robustness with array bounds checking, strong type checking, and the prohibition of uninitialized variables.

[1] ECMA International was formerly known as European Computer Manufacturers Association and is referred to herein simply as ECMA.

This chapter introduces you to the fundamentals of the language: It illustrates the basic parts of a C# program; compares value and reference types; and describes the syntax for operators and statements used for looping and controlling program flow. As an experienced programmer, this should be familiar terrain through which you can move quickly. However, the section on value and reference types may demand a bit more attention. Understanding the differences in how .NET handles value and reference types can influence program design choices.

     < Day Day Up > 

    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219 © 2008-2017.
    If you may any questions please contact us: