Nishant Nishant - 1 year ago 79
ASP.NET (C#) Question

can we inherit more then on class in aspx page?

I want to inherit more than one class is there any method?

For instance in login.aspx page:

<%@ page language="c#" codefile="nishant.aspx.cs" autowireup="true" inherit="nishant"%>

now code behind file


class nishant

class bill

Now, I want to inherit bill class then how I will ?

Answer Source

.NET does not support multiple inheritance, this includes, so no, this is not possible.

You can have your nishant class inherit from the bill class or the other way around, if you want to share functionality. You page can then inherit from the inheriting class and access the functionality of both.

Another option is to inherit from one class and implement an interface (or several interfaces), but the fact that you can implement more than one interface is not the same as multiple inheritance.

There are other things that can be done, depending on what exactly you are trying to achieve (I am primarily thinking about composition versus inheritance).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download