In this chapter, you have developed your programming knowledge by considering various structures that you can use in your code. The proper use of these structures is essential when you start making more complex applications, and you will see them time and again throughout this book.
First, you spent some time looking at Boolean logic, with a bit of bitwise logic thrown in for good measure. Looking back on this after working through the rest of the chapter confirms the initial assumption that this topic is very important when it comes to implementing branching and looping code in your programs. It is essential to become very familiar with the operators and techniques detailed in this section.
Branching enables you to conditionally execute code, which, when combined with looping, allows you to create convoluted structures in your C# code. When you have loops inside
In this chapter, you learned:
How to use Boolean logic
Techniques for structuring your code
In the
If you have two integers stored in
Write an application that includes the logic from Exercise 1, obtains two numbers from the
What is wrong with the following code?
int i; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue; Console.WriteLine(i); }
Modify the Mandelbrot set application to request image limits from the user and display the chosen section of the image. The current code outputs as many
Now that you've seen a bit more of the C# language, it's time to go back and tackle some of the more involved topics concerning variables.
The first topic you look at in this chapter is
type conversion
, where you convert values from one type into another. You've already seen a bit of this, but you look at it
Once you've covered this, you will look at a few more types of variable that you can use:
Enumerations:
Variable types that have a
Structs: Composite variable types made up of a user-defined set of other variable types
Arrays: Types that hold multiple variables of one type, allowing index access to the individual values
These are slightly more complex than the simple types you've been using up to now, but they can make your life much easier.
Once you've covered these topics, you look at another useful subject concerning strings — basic string manipulation.