Chapter 3. Conditionals and Loops


Chapter 3. Conditionals and Loops

In the last chapter you learned how to write classes. Let's briefly review what we know about classes. A lot of the concepts in this section will feel somewhat simple if you have done programming in other languages, like JavaScript, VBScript, or C++.

You learned that classes are the building blocks of applications in C#. No code can exist outside of a class. Classes have two main characteristics ”they have state and behavior. The state of the class is defined by the instance fields that the class has. The state is the information that is exclusive to each instance of the class. For example, each Checking account may have its own balance. The behavior is defined by the methods that a class has. The behavior is what you can do with the class: OpenAccount, CloseAccount, etc. For a method to do something useful you must have some code and that usually means writing loops and conditional statements.

Conditional statements enable you to execute code when a condition is true or false. Normally they are split into two code sections: the code to execute if the condition is true, and the code to execute if the condition is false. Loops enable you to execute a specific block of code a certain number of times. Loops fall into two categories: loops that execute for a specific number of times, and loops that execute while a condition is true or false.



C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

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