C # notes,

Source: Internet
Author: User

C # notes,
I. Differences between typeof () and GetType () 1. getType () gets the runtime type of the current instance. The prototype of the method is public System. type GetType () belongs to the Object instance method, that is, whether it is. both the class in the net Framework class library and the class created by the user contain this method, using the object name. getType () 2. typeof () returns a specific type of System. type object. You can use the Type object to access the base class and some information of this class. Usage: typeof (class name)

Ii. Differences between readonly const 1. readonly: You can assign a value in the constructor without having to assign a value when defining a constant. 2. const: assign values when defining constants. Iii. int. parse (), int. tryParse () and Convert. toInt32 () Difference 1.int. parse () is a type of capacity conversion. It indicates that the string of the number content is converted to the int type. If the string is null, an ArgumentNullException exception is thrown. If the string content is not a number, a FormatException is thrown. If the value of the string content exceeds the range that the int type can represent, an OverflowException exception is thrown; 2.int. tryParse and int. parse is similar, but it does not produce exceptions. If the conversion is successful, true is returned, and if the conversion fails, false is returned. The last parameter is the output value. If the conversion fails, the output value is 03. is a type-tolerant conversion, but it is not limited to converting a string to the int type, it can also be another type of parameter; comparison: Convert. if ToInt32 is null, 0; int is returned. if the Parse parameter is null, an exception is thrown. If the Convert. ToInt32 parameter is "", an exception is thrown. If the int. Parse parameter is "", an exception is thrown. Convert. ToInt32 can be converted to many types. int. Parse can only be converted to numeric strings. Iv. Icon Interpretation


C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

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.