Home > Articles > Programming > C#

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book


This chapter began with an introduction to the C# operators related to assignment and arithmetic. Next, you used the operators along with the const keyword to declare constants. Coverage of all the C# operators was not sequential, however. Before discussing the relational and logical comparison operators, the chapter introduced the if statement and the important concepts of code blocks and scope. To close out the coverage of operators we discussed the bitwise operators, especially regarding masks. We also discussed other control flow statements such as loops, switch, and goto, and ended the chapter with a discussion of the C# preprocessor directives.

Operator precedence was discussed earlier in the chapter; Table 3.5 summarizes the order of precedence across all operators, including several that are not yet covered.

Table 3.5. Operator Order of Precedence*




x.y  f(x)  a[x]  x++  x--  new
typeof(T)  checked(x)  unchecked(x) default(T)
delegate{}   ()


+  -  !  ~  ++x  --x  (T)x


*  /  %


+  -


<<  >>

Relational and type testing

<  >  <=  >=  is  as


==  !=

Logical AND


Logical XOR


Logical OR


Conditional AND


Conditional OR


Null coalescing




Assignment and lambda

= *=  /=  %=  +=  -=  <<=  >>=  &=  ^=  |=  =>

Perhaps one of the best ways to review all of the content covered in Chapters 1–3 is to look at the tic-tac-toe program found in Appendix B. By reviewing the program, you can see one way in which you can combine all that you have learned into a complete program.

  • + Share This
  • 🔖 Save To Your Account