First, the difference between class and structure, respectively, what are the applications. (Reference: https://blog.csdn.net/yikeshu19900128/article/details/40400479 )
1) The class is a reference type, the data is stored on the heap, and the pointed address is stored on the stack. Structures are value types, and data is stored on the stack.
2) Classes can inherit, can inherit another class or interface, and can also be inherited. Structs cannot inherit, cannot inherit from another struct or class, and cannot be inherited, but interfaces can be inherited.
3) Classes can be initialized at declaration time, structs cannot be initialized at declaration time.
4) In a class, once we write the parameterized constructor, the default constructor does not exist. When we want to call a constructor with no parameters to initialize an object, we have to write another constructor without parameters ourselves. But in a structure, there is always a default constructor with no parameters, and this constructor is irreplaceable and cannot be overridden or overridden. In a structure, we can only write a constructor with parameters, not constructor with no arguments
5) Destructor: A class has a destructor, but a struct does not have a destructor
6) Keywords: keywords that can be used in classes but restricted in structures are: abstract, sealed, protected; Static keywords can be used in front of the class name to declare static classes, but cannot be used in front of struct, no there is a static structure
7) Classes use new to instantiate objects and allocate memory, and need to use new to return the address and allocate space, while structures are initialized with new, and structures are value types, and memory has been allocated when they are declared.
Analysis of applicable occasions for structures and classes: (Reference: https://blog.csdn.net/Iqingshuifurong/article/details/53129536 )
1. When the stack space is very limited and there are a large number of logical objects, it is better to create a class than to create a structure;
2. For lightweight objects such as points, rectangles, and colors, if you want to declare an array containing many color objects, the CLR needs to allocate memory for each object. In this case, the cost of using the structure is lower;
3. Classes are the best choice when representing abstraction and multi-level object hierarchies, because structs do not support inheritance.
4. In most cases, the target type only contains some data, or mainly data.
2. What is the difference between using sql statement directly and querying with stored procedure in the project (reference: https://www.cnblogs.com/binyue/p/6442310.html )
3. What are the ways to optimize the website? (Explain from both the server and the client side) (Reference: https://www.zhihu.com/question/21658448 )
[If you know this, I hope you can share your answer in the comment area, thank you]
<script type="text/javascript"> var a = '12.3'; a = parseInt(a);//a=12 var b = 12.6; var c = a + b;//c=24.6 alert(typeof (c));//number类型 alert(parseInt(c));//24 </script>
<script type="text/javascript"> var a = '12.3'; a = parseFloat(a); var b = 12.6; var c = a + b; alert(c); // 24.9 alert( typeof (c)); // number type alert(c.toFixed( 0 )); // 25 rounding function tofixed(n) in js, n is the decimal to keep digits. n is 0~20, when n exceeds 20, js will make an error. </script>