C # Summary of basic knowledge points,

Source: Internet
Author: User

C # Summary of basic knowledge points,

No information will be lost during conversion

The explicit conversion condition of the type is relative to the above

<1> You must assign a value to the local variable when reading and obtaining the money.

<2> function parameters must be provided when a method is called.

<3> all other variables (such as fields and array elements) are automatically initialized at runtime (use the default values of their types)

 

Default Value of all reference types: null

Default values of all values and enumeration types: 0

Default character type: '\ 0'

Boolean default value: False

You can use the default keyword to obtain its key value.

 

The indexer is compiled into the get_Item () and set_Item () methods in the system.

 

28.4 initialization sequence of constructor and Field

(1) From subclass to base class: initialization field à specifies the variable in the constructor of the base class to be called

(2) From base class to subclass: Constructor

 

 

  • Call the GetType () method on the instance of the class
  • Use the TypeOf operator on the class name

    The difference between the two is that GetType is assigned at runtime, while TypeOf is assigned at compilation.

  • Public: full access permission, which is the implicit access permission of Enumeration type members or interfaces.
  • Internal

 

  • Private: only visible within the type. default access permissions for class and struct members
  • Protected: Visible only in the class and subclass
  • Explicit interface implementation

    When multiple interfaces are implemented, sometimes the member IDs conflict. In this case, you can explicitly implement the interface to solve the conflict.

    Public Interface ITest {

    Void DoSomething ();

    }

Public class Test: ITest {

ITest. DoSomething () {}// explicit IMPLEMENTATION OF THE INTERFACE

}

Note: The only way to call an explicitly implemented member is to convert the object to the corresponding interface.

Test t = new Test ();

(ITest) t. DoSomething ();

  • Virtual method implementation interface member

    By default, the implementation of interface members is implicitly defined as sealed. To be reloaded, the base class must be identified as Virtual or abstract

     

    Public class Test: ITest {

    Public virtual void DoSomething (){}

    }

    Note: explicitly implemented interface members cannot be identified as virtual

     

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.