简体   繁体   中英

can one class inherit from an other class an have implemented an interface at same time?

somthing like

public partial class RegistrationForm : 
          IRegistrationForm, System.Web.UI.UserControl

but this example does not work.

Yes, but you do it like this:

public partial class RegistrationForm : System.Web.UI.UserControl, IRegistrationForm

C# doesn't support multiple inheritance, so you put the class you inherit from first, followed by a comma, followed by a comma-delimited list of the interfaces it implements.

Absolutely, a class can inherit from a single base class and implement any number of interfaces at the same time.

Your example does not work because the one base class must be listed first, before all the interfaces...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM