1. Introduction to the. NET Framework principles, two compilation of C # programs
. NET source code-to-language compiler (first compile)-->msil+ metadata (EXE file)-->clr (Common language runtime-similar to JRE)-Machine code (second compilation)-code is executed
What is a 2.Main function? What do you need to be aware of when using the main function in your program?
The entry function of the program! The function name cannot be changed, and there is only one main function in a program.
What is 3.CLR? What is an assembly? What does the CLR do when it runs an assembly?
Common Language Runtime Common language runtime. ( similar to JRE)
A collection of compiled code. (including EXE and DLL). Loads all the classes in the project into memory, finds the main function in it, and executes as the default startup function call.
4. What is the default value for a value type? (Case one: field or global static variable; case two: local variable)
If it is a global variable and is not assigned a value, there will be a default value, such as: int is 0;bool false; enum enum; structure struct;
If it is a local variable, you must assign the value manually.
5. What does it do in memory when declaring a variable? What happens in memory when you initialize a variable?
Space is created in the stack, and the variable is placed in space, and the default value is null.
When initializing:
If it is a value type, it is placed directly in the stack;
If it is a reference type, create a space in the heap to put the address pointers of the objects in the heap into the stack
6.new keywords to do things?
Open space, create objects, call constructors, return heap addresses.
You can also display a method that hides the parent class with the same name.
7. Once the array is created, can you modify the length of the array?
No. Because the array is a reference type. It creates a contiguous space in memory based on the length of the creation.
8. Multidimensional arrays--essentially, an array, but access requires multiple subscripts to access it.
1), How do I declare a multidimensional array?
Multidimensional array string[,] strarr=new string[3,3];
2 ), how to get the total length of a multidimensional array
Product of the number of elements in each latitude
9. Jagged arrays
- How do I declare a jagged array?
Jagged array: int[][] arr=new int[3][3];
- What is the nature of a jagged array?
The essence is an array of arrays. Simply put, the element of this array is an array.
10. Methods
- Why should there be a way?
To improve the reusability of the Code, the implementation is reusable (encapsulation is implemented)
- How to implement overloading of methods
Method name is the same, but the parameter list is different, regardless of the return value
- Reference parameter "ref" and output parameter "out" the same points and different points
Same point: The Pass is a (stack) reference
Different points:
1.out focuses on the output; ref focuses on modification;
2.out must be assigned before the method returns, and ref must be assigned before passing in.
11. Three main features of object-oriented:
Encapsulation, inheritance, polymorphism
12. Class-To-object relationships
A class is abstract, a collection of things that have the same characteristics or the same behavior (a class is a set of objects that have the same data structure and the same operations ). (e.g. human)
An object is a specific individual in a class. (for example, a person is a human object)
Simply put: A class is an abstract description of an object, and an object is a class's materialization.
13. What happens in memory when you create an object of a class? (For example: person p = new person ();)
Open space, create objects, call constructors. (Space in the memory stack, create a Person object, and then open a space in the memory stack to put a p, and assign the person object to the object P in the heap's reference address)
14. What is the purpose of the existence of the attribute?
Encapsulates a field. Set up rules for the operation of the field. In essence, it is two methods, a Get method, a set method
15. Access Modifiers
Public: Common, used in any class
Private: Used in this class
Protected: Protected, used in this class and in derived classes
Internal: Internal, used in namespace
extern: For external access (C # provides interface for C + + access)
16. Why do I have a constructor function
The purpose of this is to facilitate the initialization of some properties and fields in the object when the programmer instantiates the object.
17. What is encapsulation? What is the purpose of encapsulation?
Encapsulation is the "integration" of the object's fields, behaviors, and functions to make it easy to use
Purpose of Encapsulation: Hide code Implementation, implement code reuse, easy to modify and maintain
18. What are the naming conventions for classes and variables?
Class: Capital letters (Pascal naming rules)
Variable: First letter lowercase (camel naming convention)