Objective
- Actually very early wanted to write about the C # Foundation, always self to find excuses, or to search the Internet to look at, now think I feel a little lazy ... As a developer, the basic knowledge is the most serious, only to consolidate, understand, practice to improve their skills. It is also hoped that through this series, we can help those who need to consolidate the foundation.
Base keyword
- Calling a method that the base class has been overridden by a derived class
Public classFather { Public Virtual voidSay () {Console.WriteLine ("Father Say"); } } Public classSon:father { Public Override voidSay () {Base. Say (); Console.WriteLine ("Son Say"); } }
- Call the constructor of the base class when specifying a derived class instance
Public classFather { Public stringName {Get;Set; } PublicFather () {Name="Father"; } } Public classSon:father { PublicSon ():Base() { } }
- The use of base in EntityFramework, such as:
- Note: The base keyword cannot be used in a static method.
C # basic Knowledge Base keyword