|
|
|
SummaryIn this chapter, we explored the underpinnings of the .NET platform. This tour included topics covering the built-in security provided by the Common Language Runtime, along with the cross-language support and common data types. In addition, you've seen your first C# example in this book. |
|
|
|
|
|
|
Further Reading
Programming C# , Third Edition by Jesse Liberty, O'Reilly. ISBN: 0596004893. The Applied Microsoft .NET Framework Programming in C# Collection , Microsoft Press. ISBN: 0735619751. |
|
|
|
|
|
|
Chapter 3. Expressions and Control StructuresIN BRIEF In this chapter, we will explore the basic control structures provided by C#. Each of these constructs will be explored and discussed in terms of syntax and proper usage. WHAT YOU NEED
EXPRESSIONS AND CONTROL STRUCTURES AT A GLANCE
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
|
Expressions and Control Structures
The goal with any programming language is to
implement application logic in order to achieve the desired
functionality. C# is a modern language that offers traditional
expressions and control structures along with a few new ones to
simplify the development process. In addition, C# is a type-safe
language and enforces type safety at various levels. Such adherence
to type safety is both a blessing and a curse. Depending on the
language you're familiar with, some of your old habits will cause
you a lot of frustration with C# because it enforces correct code
and type safety. The purpose of this chapter is to explore the type
safety offered by C# while delving into the expression syntax and
control structures
|
|
|
|
|
|
|
Basic Expressions
An
expression
is defined as a syntactically correct program statement. However,
for the purpose of this chapter, the expressions we're most
interested in revolve around assignment and evaluation, and
true/false determination. An assignment expression has at least one
variable and one value to be assigned to that variable. Such is the
case of declaring an integer value and assigning it the default
value of 10. All
int i; //C# complains about the uninitialized variable C# requires all variables to be initialized before usage. The variable can be initialized during declaration or before its first usage. However, it's best to initialize a default value during its declaration; doing so will aid in future debugging attempts. |
|
|
|