Skip to Content
Beginning C# 3.0
book

Beginning C# 3.0

by Jack Purdum
May 2008
Beginner
550 pages
13h 22m
English
Wrox
Content preview from Beginning C# 3.0

Chapter 6. Making Decisions in Code

If computers could not use data to make decisions, they would be little more than very expensive boat anchors. Because it is hard to write a nontrivial program without some form of decision-making ability in it, I have used some decision-making keywords in previous programs. However, I never really explained what those keywords actually do. That changes by the end of this chapter. In this chapter, you will learn about:

  • Relational operators

  • Comparing value types

  • Comparing reference types

  • The if and else keywords

  • Cascading if statements

  • Logical operators

  • The switch, case, break, and default keywords

  • Data validation

This chapter also presents some thoughts on coding style. Coding style simply refers to the way you write program code. There are myriad coding styles. Because C# is not form-specific, you are free to use just about any coding style you wish. The author has known brilliant programmers whose code is almost impossible to read or decipher. On the other hand, I've had mediocre students who write code that is a joy to read. True, beauty is in the eye of the beholder. However, experience has taught me that 80 percent of a program's development time is spent in testing, debugging, and maintaining the code, and only 20 percent in writing it. For that reason, anything you can do to make your code clearer and more easily understood is a good idea.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Capitalism at Risk

Capitalism at Risk

Joseph L. Bower, Herman B. Leonard, Lynn S. Paine

Publisher Resources

ISBN: 9780470261293Purchase book