13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: C# and <strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong> 61Ask the ExpertQ: What are the m characters doing in the literals for the cost and tax values?A: When assigning literal values to decimal type variables or constants, you have to add the mcharacter to distinguish the value from integers, doubles, or some other kind of nondecimaltype literal. Note, however, that the variables containing decimal values need not includethe m.The cost variable uses an addition <strong>com</strong>pound operator to add itself to the value of the costmultiplied by the tax variable using a multiplication <strong>com</strong>pound operator.Relational OperatorsWhen two or more elements in an expression are <strong>com</strong>pared, relational operators generateBoolean true or false values. Generally, values of the same type are evaluated asbeing equal to one another or somehow different. Table 3-3 shows the primary relationaloperators and a brief description of what they do.Relational operators are used widely with conditional statements both within and apartfrom loops. They can also be used to establish the value of Boolean constants or variables.The important fact to remember is that relational operators always evaluate to true orfalse. Consider the following code:int first = 10;int second = 20;bool same;same= (first == second);//same resolves to falseSymbolDescription== Equal to!= Not equal> Greater than< Less than>= Greater than or equal to

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!