In Brief

This chapter provided an overview of several introductory topics in C# programming.

  • C# classifies managed types as either reference types or value types. These types have different behavior, which affects the way a program operates. Value types copy the full contents of a type during assignment and are allocated on the stack, whereas reference types copy only a reference to their object that is allocated on the heap.

  • C# has several branching and looping statements that may be used to control the flow of execution in a program. The if and switch statements allow code to branch, based on a Boolean condition or the value of a parameter, respectively. Loops include while, do while, for, and foreach. There are also branching statements such as break, continue, goto, and return that alter the flow of program execution.

  • There are three types of arrays that may be used with C# programs: single-dimension, multi-dimension, and jagged. A single-dimension array contains one row of a specified type. Multi-dimension arrays allow you to specify the number of dimensions that the array has. Jagged arrays allow you to create arrays within arrays, where size may differ between two or more subarrays.

  • Methods are similar to functions in other languages, allowing you to divide code into logical sections. A method's parameters may be a combination of value, ref, out, or param parameter types. Without a parameter type specifier, parameters are copied by value. A ref parameter copies a reference to an object to a method. An out parameter only returns a value or reference to an object, but no object reference is passed in. The params parameter is used for passing a variable number of arguments to a method.

  • Properties are type members that may be used like a field (variable) but have get and set accessors that may be used for validation or other housekeeping associated with the state of an object. Indexers enable a type to be used as if it were an array, using the [] syntax. They are similar to properties in that they have get and set accessors.



C# Builder KickStart
C# Builder KickStart
ISBN: 672325896
EAN: N/A
Year: 2003
Pages: 165

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net