C #: Usage of base (base after colon)

Source: Internet
Author: User

C # about: Base () usage, record here for easy access

1.this is the identity of the current resource object, and base is parent-based.

2.base played the role of the soul level-polymorphic

3.base subclasses can access parent class members

4.base calling the parent class method must override the parent class method

5.base sub-class constructor direct access: Base Parent class construction method

6.base is also not available for static methods

 Public Abstract class Httpbasedtransport:clienttransportbase    {        protectedstring  transportname)             Base (HttpClient, Transportname)        { }    }

Parent class

 Public Abstract classClienttransportbase:iclienttransport {Private ReadOnlyihttpclient _httpclient; Private ReadOnly string_transportname; Private ReadOnlyTransporthelper _transporthelper; Private ReadOnlyTransportaborthandler _aborthandler; Private BOOL_finished =false; PrivateTransportinitializationhandler _initializationhandler; [SuppressMessage ("microsoft.reliability","Ca2000:dispose objects before losing scope", justification ="disposed in the Dispose method.")]        protectedClienttransportbase (Ihttpclient httpClient,stringtransportname): This(HttpClient, Transportname,NewTransporthelper (),NewTransportaborthandler (httpClient, Transportname)) {        }        InternalClienttransportbase (Ihttpclient httpClient,stringTransportname, Transporthelper transporthelper, Transportaborthandler Aborthandler) {            if(HttpClient = =NULL)            {                Throw NewArgumentNullException ("httpClient"); }            if(string. Isnullorwhitespace (Transportname)) {Throw NewArgumentNullException ("Transportname"); } Debug.Assert (Transporthelper!=NULL,"Transporthelper is null"); Debug.Assert (Aborthandler!=NULL,"Aborthandler is null"); _httpclient=httpClient; _transportname=Transportname; _transporthelper=Transporthelper; _aborthandler=Aborthandler; }    }

(GO) C #: Usage of base (base after colon)

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.