Good day. I am just wondering how to create a base class and use it for my business objects. The base class would have some attributes like IsNew, IsDirty etc.
- What I want to know is how to
inherit this base class ? - Also what does the ‘base’ syntax
means ? Is it always required to use ‘base’ to access the base class ? - How many base classes can I have ?
- Can you show me a little sample
I did google but it was sort of confusing. Here I would get a quick answer. Thank you.
Any class which is not sealed can be a base class.
To inherit from a class, the syntax would be
in C#, the base keyword is used to refer to the parent class from within the child class.
Since there is no multiple inheritance i.e a class can have only one immediate parent class, base refers to that parent
I dont think it is always required to use base.XYX to use the base class. This kind of syntax is commonly used for constructors to call the base constructor or to invoke base members which might be over-ridden
More details on base here