Inherit Overrides

  • Thread starter Thread starter SS IT Services LLC
  • Start date Start date
S

SS IT Services LLC

I have build class Customer (public) which contains a virtual SAVE method.

Now I have build another class called Customer_ext which inherits Customer
Class thus exposing all the properties and methods.

Now I want to force programmers to use the Customer_ext class versus being
able to use the Customer class itself. Is this possible? Is there a way
that I can block someone from enstanciating the Customer class now that I
have it extended?

Thanks in advance.
 
Peter Morris said:
public abstract class Customer()
{
}

To clarify an abstract class, in addition to abstract members, can contain a
full set of virtual and concrete members, its just that it can't be
instanced as is, it must be inherited by another class that is not abstract
to create a type that can be instanced.
 
awesome thanks,

Is it possible to also hide it from intellisense so the developer wouldnt
see it
 
You can mark it "internal" in which case it is only accessible to classes
within the same assembly, or any assembly you explicitly identify using the
InternalsVisibleToAttribute.
 
Peter Morris explained :
You can mark it "internal" in which case it is only accessible to classes
within the same assembly, or any assembly you explicitly identify using the
InternalsVisibleToAttribute.

No, I don't think that will work: if you try to inherit a public class
from an internal class, you will expose the members of that internal
class. The compiler complains (with an error) about "inconsistent
accessibility".

I don't think you can hide that baseclass.

Hans Kesting
 
Back
Top