• Home
  • Forum
  • Terms and Privacy
17ebook! free ebooks! free download!
Complete online surveys and earn cash from GlobalTestMarket


Search here...
     

“C # Nature” study notes (f) operator

Posted by admin 30 November, 2010

FREE Diabetes Recipes eBook! Click here to redeem.C # Nature study notes (f) operator

Operator usually divided into three categories: unary, binary operators, the ternary operator. Their corresponding operands are 1, 2 and 3.

Unary operator used to specify a negative value (decimal a =-2234234234234234.72M)

Binary operators require two operands are called the left operand and right operand. Binary operator code also requires the assignment of results to avoid losing the results of value. Binary operator into plus (+), subtraction (-), multiplication (*), divide (/), and remainder (%, sometimes referred to as the modulus operator.)

Binary operator precedence is as follows:

1 ).*,/ and% 2). + And – 3) .=

If the binary operator of the addition operator for strings, the string will play a role in splicing.

The use of characters in the arithmetic

While the char type is stored in the character and not numbers, but it is an integer type. It can join with other integer types of arithmetic operations. However, how to explain the value of type char, not based on stored in one of the characters, but on the basis of its value. For example, the number 3 contains a Unicode value of 0 × 33 (hex), converted to decimal value is 51. Figure 4 contains the Unicode value of 0 × 34, or decimal 52.

Cause unexpected floating-point types are not equal

Floating-point types float and double have some specificity, such as the way they handle precision.

A float with a 7-bit accuracy, which can hold values of 1234567 and 0.1234567. However, if the float value of the two added together, the results will be rounded up to 1234567, since the fractional part of a float can hold more than 7 digits. This type of rounding is sometimes fatal, especially in repetitive calculations or to check the time for equality.

In comparing the two values are equal, when the inaccuracy of floating point types can cause very serious consequences. Sometimes, the value should have been equal wrongly judged as not equal.

There are other special floating-point type. For example, an integer divide by zero, in theory, should result in an error. For the exact data type, this point is established. Then, float and double to allow some special value. Floating-point divide by zero, indicating “not a number”

float n = 0f; System.Console.WriteLine (n / 0); Output: non-numeric

Parentheses operator

Parentheses operator to allow combination of operands and operators, so that together they can find value. This is important because it provides a way beyond the default priority. Developers should take the initiative to use parentheses to enhance readability of the code to show the expression to eliminate the ambiguity, rather than relying on operator precedence.

Increment and decrement operators

C # provides special operators to implement counter increment and decrement. Increment operator (+ +) incremented by 1 each time to make a variable. Decrement operator (-) reduced by 1 each time to make a variable.

The contrast increment operator prefix and suffix

class IncrementExample

{

public static void Main ()

{

int x;

x = 1;

System.Console.WriteLine (“{0}, {1}, {2}”, x + +, x + +, x);

System.Console.WriteLine (“{0}. {1}, {2 }”,++ x, + + x, x);

}

}

Output:

1,2,3

4,5,5

It can be seen, the prefix increment / decrement operator returns the number of operating the up / down after the results, and the suffix increment / decrement operator returns the number of operating the up / down before the results.

Thread-safe increment and decrement

Used by System.Threading.Interlocked class provides thread-safe method Increment () and Decrement (). Both methods rely on the function of the processor to perform fast, thread-safe increment and decrement.

Constant expression

By definition, a constant expression is the C # compiler can be evaluated at compile time expression.

const keyword will lock the value at compile time. After the lock code, the value of any amendment or attempt will cause a compile error.

public Long Main ()

{

const int a = 60 * 60 * 24; / / constant expression

const int b = a * 7;

}

Note that the value assigned to b is a constant expression, because the operand expression is constant, so the compiler can determine the outcome.

Logical operators

Logical operators have one or two Boolean operands and returns a Boolean result. Logical operators allow you to combine multiple Boolean expressions to form other Boolean expressions. Logical operators, including ||,&& and ^, corresponding to OR, AND, XOR.

1.OR operator (| |)

| | Operators on two Boolean expressions are evaluated, and if any one is true, it returns true

2.AND operator (& &)

Boolean AND operator & & require both operands are evaluated only under the precondition for the true return true. Any operand is false, returns false.

3.XOR operator (^)

^ Symbol is the XOR operator. If applied to two Boolean operands, only a few in only one of the two operating under the premise is true, XOR operator will return true.

With the Boolean AND and OR is different from the Boolean XOR operator does not support short-circuit operations. It always have to check the two operands, because unless know exactly the value of both operands, or can not determine the final result.

Logical negation operator

Logical negation operator (!) Sometimes called NOT operator, its role is reversed value of a bool data type, which is a unary operator, only one operand.

Conditional operator

You can use conditional operator instead of if statements. The conditional operator is a question mark (?), The general format is as follows:

a? 1:2;

The conditional operator is ternary operator, because it requires three operands: a, 1,2.

If a request is true, then the conditional operator returns 1, otherwise 2.

Categories : book review Tags :

Comments

No comments yet.


Sorry, the comment form is closed at this time.

Subscribe via Email


Windows Touch Technics and Technology tablet Solution Manual Smart Security/Hacking Science Related Science/Engineering samsung Review Programming Phones phone Nokia Newspapers netbooks Netbook Mobile Medical/Medicine Laptops Laptop IT Certification Iphone Hobbies Health Graphics and Design Google Game For Women For Men features Ericsson Encyclopedias Economics and Finances Economics/Business deals DB Consumer Electronics Computer Related Computer Comics Apple android about
  • Categories

    • book review
    • Ebook Download
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Archives

    • May 2013
    • April 2013
    • March 2013
    • February 2013
    • January 2013
    • December 2012
    • November 2012
    • October 2012
    • September 2012
    • August 2012
    • July 2012
    • June 2012
    • May 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
  • Recent posts

    • Sony Ericsson Xperia Play: Pricey Handset, But Priceless Features
    • HTC Touch2 smart house windows cellular Review
    • Questions about Windows Phone 7
    • Android technology comes of age within the HTC Tattoo
    • Android Handsets And Tablets: Operate Your Microsoft Windows Apps From Your Very Own Mobile Gadgets
    • The evaluation of BlackBerry 9700: the most perfect business phone
    • Toshiba TG01 Comes with Plethora of Features
    • Predications Of The Smart Phone Market
    • Nokia Lumia 710 Designed for you
    • Why The HTC EVO 4G Tablet Should Be Considered If You Are After A Tablet PC

Copyright © 2013 17ebook! free ebooks! free download! All right reserved

  • Home
  • Forum
  • Terms and Privacy