C # Basic _ console program _ calling namespace _ basic knowledge point 1, cf
C # Basic _ console project_call namespace _ basic knowledge point 1
Purpose:
Try to call the non-static method show () of Class B by instantiating B in the Mian () method of Class ()
Originally written in the program. cs file, that is, the following code 1.1.1
// Code 1.1.1
1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. text; 5 // using AB; 6 7 namespace ConsoleApplication1 8 {9 10 class Program11 {12 static void Main (string [] args) 13 {14 B B = new B (); 15 B. show (); 16 Console. readKey (); 17 18} 19} 20} 21 22 class B23 {24 public void show () 25 {26 Console. writeLine ("show cross-class calls"); 27} 28}
<Because the default modifier of Class B is internal, it is considered that if Class B is written in the namespace containing Class A, it cannot be called, however, it can still be called during actual operation. What cannot be called is to put Class B in another namespace separately. For details, see Code 1.1.2>
// Code 1.2.2
1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. text; 5 // using AB; can also be placed here 6 7 namespace ConsoleApplication1 8 {9 using AB; 10 class Program11 {12 static void Main (string [] args) 13 {14 B B = new B (); 15 B. show (); 16 Console. readKey (); 17 18} 19} 20} 21 22 namespace AB23 {24 class B25 {26 public void show () 27 {28 Console. writeLine ("show cross-class calls"); 29} 30} 31}
Later I tried to call the header file of the original c ++ style.
As follows, the Program. cs and Class1 codes are 1.1.3 and 1.1.4 respectively.
10:58:30 is as follows
// Code 1.1.3
Using System; using System. collections. generic; using System. linq; using System. text; using AB; namespace ConsoleApplication1 {// using AB; class Program {static void Main (string [] args) {B B B = new B (); B. show (); Console. readKey ();}}}
// Code 1.1.4
Using System; using System. collections. generic; using System. linq; using System. text; namespace AB {class B {public void show () {Console. writeLine ("show cross-class calls ");}}}
In 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 & |! What is the? & operator used to extract the address of a variable.
For example, if you define a variable, the system will allocate a space in the memory during compilation.
The location of the space in the memory is its address. & Extract its address.
E. g int a; assign an address to it during compilation, for example, 2000; & a is 2000.
If an integer pointer Variable p, p = & a; is defined, the address 2000 of a is assigned to p. P = 2000 after running.
Another example is scanf ("% d", & a). When you enter 3, it first knows the address of a according to & a, and finds the space of a in the memory by the address, write 3 to this space.
* Is a pointer operator, which is opposite to &. It extracts the value of a Variable Based on the address of the variable.
For example, * the value of a is 3 of variable.
The following is a summary of the pointer used in the definition and description.
Int * p; defines a pointer to integer data.
Int * p [n]; defines the pointer array p, which consists of n pointer elements pointing to integer data.
Int (* p) [n]; p is the pointer variable pointing to a one-dimensional array containing n elements.
Int * p (); p is the function that returns a pointer pointing to integer data.
Int (* p) (); p is the pointer to the function. This function returns an integer value.
Int ** p; p is a pointer variable that points to an integer Data Pointer variable.
If you want to learn more about the system, you can refer to tan haoqiang's c Programming (the third edition), which is easy to understand. Is a good C language learning material.