*************************************
* Pay attention to your own name,
* [JIT] on-The-fly compilation: Where to compile the run to, and then put into memory after compilation.
* Local variables (declared in the method) must be first paid in use.
* The more abstract class can be used as the parent class.
* Richter Replacement principle:
It is possible to give the object of a subclass when the type of the parent class is needed.
*: Shortcut keys
* Import Namespaces (SHIFT+ALT+F10)
* Constructor: CTOR
*: Base (): Represents the constructor that invokes the parent class
**this to invoke the members of this class, base to invoke the members of the parent class.
* * Access level constraint
* Multi-State implementation
*: Static constructor
*: All members that are contained in a static class must be static members. Static properties are only used with the class name. Come out, you can't use an Instanced object to point it out. < static members have a long life cycle, which is typically reclaimed when the program exits, and the instantiated objects are recycled by GC once they are exhausted. >
* When recording code, remember its main structure, the main step.
This is the declaration of a static property inside a class, followed by a hidden static constructor. Static constructors execute only once, (static classes are used first, static members, static methods)
Static constructors cannot be called manually, but are automatically invoked the first time a static class is used, without an access modifier or any parameters. The specific value is set in the inside.
Polymorphic < The same piece of code has different functions during execution >
* Another type conversion of type
< Just this conversion does not prompt the error, the value becomes null, and the strongly typed conversion directly reports the exception. >
Student a=p as Student ();
* Abstract class
"Just add an abstract to the class before the class"
The general class is abstract, but abstract classes are more advanced abstract classes that cannot be instantiated.
The following are general characteristics of abstract classes
Abstract classes are only defined in which there is no specific implementation, and intelligence is overridden in an inherited subclass.
* Note that when you use class properties later, you place them in the constructor (CTOR) when assigning values to their properties.
* * Practice Example
*: Value type and reference type
Value type: stored in bytes in memory "save in stack", not inheritable
<int Char double long short enum decime >
The reference type, in the heap, the stack inside has the preservation, in the stack only holds the heap inside the address, the actual value is puts in the heap inside. can inherit
<string Array class interface, Delegate >
< reference passing, value passing >
...... Reference passing: The heap address in the copy stack, pointing to the same heap;
... ref's reference pass: Two variables point to the same stack (with data in the stack), and that is the same heap they point to, regardless of the change, the data in the heap will change.
...... Value passing: Copies the contents of the stack as a copy.
(When the data in the stack is copied, it is a copy of the data.)
*: Discussion of interface problems
In Java, the teacher said to look down the floor above the pipeline, so you can think of the specific meaning of the interface.
Definition and naming of interfaces
* The general interface starts with capital I,-able ends, and the keyword is interface
* The interface can only contain methods (methods, properties, indexers, events).
* The interface cannot write any access modifiers. Access modifiers in the < interface that are public by default >
* The interface cannot be instantiated, the attribute can only be written (Get;set;) method, can not continue to write.
* The member subclass in the interface must be fully implemented. Interfaces can "inherit multiple" a class can inherit from only one parent class but can implement multiple interfaces.
public class Interface Iflyable
{
Void Sayhi ();
Indexer
String This[int Index]
{
Get;set;
}
}
*: interface instance
The implementation of the interface is divided into two, direct implementation, display implementation of the interface, the direct implementation is public, and the display implementation interface is to solve the problem of duplicate name, private.
* Type Conversion
* Explicit conversions, implicit conversions, strongly-typed conversions (easy to lose precision)
1:sizeof determines how many bytes it occupies,
{Console.WriteLine (sizeof (int))}
2: Type conversion occurs implicitly when the data type is the same, and the large bytes are converted to small bytes. )
3: The parent class of all arrays is the array type.
* Exception handling <try---catch----finally>
* Run-time program error
*finally: Code cleanup, freeing up resources, whatever happens it's inside the content will be executed. Quite with the meaning of the define behind switch in C language.
* When a line of code in the program goes wrong, the subsequent code does not execute backwards.
* For exception handling we can write multiple catch (the exception method is different) to handle the individual exceptions.
* Manual Exception Throw < more use logical judgment to resolve exception. In order not to waste resources. >
Throw New Exception ("with exception")
The * method sets a separate variable for the return value, so the value inside the return value will not change.
Ref and out comparisons
* Compare two objects for the same object
Console.WriteLine (object. ReferenceEquals (P1,P2));
Console.WriteLine (object. ReferenceEquals (P1,P3));
If P1 and P2 are the same object, the return value is true, but the return value is False if not.
* Keyword sealed< this is for sealing class >
Precede it with a keyword sealed to indicate that this class is not inherited.
* String non-denaturing and string pooling
The addition and subtraction of 1:string is the superposition of strings, which will open up new heap memory.
2: The save of string constants will be saved to the heap memory, which is saved in the string pool. Also quite with save into the block table inside. <string. Isinterned () >
* String
1: String formatting
Here is the replacement of the place symbol, Console.WriteLine ("I Am (0,-10,c2) year old", 22);
Use of the 2:stringbuilder class
The general situation is used when the string concatenation is used, because it is fast.
3: How to monitor the speed of C # programs such as strings
Instantiate the Stopwatch object before the program that needs to add the watch.
Stopwatch watch=new Stopwatch ();
Watch. Start ()
This is the program that needs to see the execution time.
Watch.stop ();
Console.WriteLine (watch. Elapsed);
4: Weak references
Is the variable after the initialization is completed, there is no address in the stack to it, then it will be GC recycling, at this time with WeakReference re-affirmed, that is, its weak reference, the future use of the direct use can be used. <weakreference wr=new WeakReference (P) >
A messy little knowledge