Small knowledge (2), small knowledge

Source: Internet
Author: User

Small knowledge (2), small knowledge

Bitwise OPERATOR:

And: & when the binary bits are both 1, the result is 1, otherwise 0. Binary calculation, by-bit comparison.

Or: | if the binary bit is 0, the result is 0. Otherwise, 1 is returned. Binary calculation, by-bit comparison.

XOR: ^ if the binary phase is the same, the result is 0. Otherwise, 1 is returned. Binary calculation, by-bit comparison.

Reverse :~ If the binary value is 0, the result is 1. Otherwise, the value is 0. One-dimensional calculation, by-bit comparison.

Left shift: <equivalent to n power of 2. Binary operation.

Right Shift:> is equivalent to n power except 2. Binary operation.

Logical operators:

Or: | if both bool values are false, the result is false. Otherwise, the result is true. Binary operation.

Non-logical :! If it is false, the result is true. Unary operation.

When both the logical and: & and bool values are true, the result is true; otherwise, false. Binary operation.

Placeholder:

Placeholders are often used when we use Console. Write/Console. WriteLine, such as Console. write ("{0}", I );

The placeholder {0} must start from scratch and be smaller than the parameter list size.

You can use Console. WriteLine ("{0} {4}", 6, 9, 9, 2, 4); in this way, output 64.

Console. WriteLine ("{0: x5} {4}", 6, 9, 9, 2, 4); Output 000064, note: x5

Ask the master to ask how to do binary output by 8 bits? For example, binary 100 is output to 00000100. You do not need to add the 0 method before string Conversion. How can this problem be solved ???

GetType ():

Obtain the type of the current instance. For example, int I = 1; Console. WriteLine (I. GetType (); output: System. Int32

GetTypeCode ():

Returns the basic TypeCode of the instance.

Var I = 1;

If (I. GetTypeCode () = TypeCode. Int32.GetTypeCode ())

{......}

Is:

Bool Value

If (I is int)

{.....}

As:

Object obj = new Object (); creates a base class Object.

Program p = obj as Program; If obj (reference) is not compatible with the Program class, the result is null.

If (p = null)

{......}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.