base keyword in c#
In c#, to access members and functionalities of the base class, the 'base' keyword is used within a derived class. In the given code, we have used 'base' keyword to call the constructor of the Account class.
In the below code, the derived class constructor - 'PartyAccount' receives the values first and which are then passed to the base class constructor.
Note : The 'MyBase' keyword in vb.net is the counterpart for the 'base' keyword in c#.
class Account { private string mCode; private string mName; private string mdescription; private double mBalance; public Account(string code, string name, string description, double balance) { mCode = code; mName = name; mdescription = description; mBalance = balance; } public Account() { }
In the below code, the derived class constructor - 'PartyAccount' receives the values first and which are then passed to the base class constructor.
class PartyAccount :Account { private string mAddress; private string mPhone; public PartyAccount(string code, string name, string description, double balance, string address, string phone) : base(code, name, description, balance) { mAddress = address; mPhone = phone; } public PartyAccount() : base() { }
Note : The 'MyBase' keyword in vb.net is the counterpart for the 'base' keyword in c#.
Object Oriented Programming Articles
- Abstract class constructors
- abstract class inheritance in c#.net
- abstract class inheritance in visual basic.net
- New C# Language Feature: Automatic Properties
- Calling base class constructor in C#
- base keyword in c#
- Compile time polymorphism - Method OverLoading
- How to initialize Base class Object from inside Derived Class constructor
- Constructor overloading in vb.net
- How to use inheritance in c#
- How to use inheritance in visual basic.net
- Parameter array in vb.net
- Procedure OverLoading in vb.net
- Visual Inheritance with Windows Forms
- Azure Platform
- GridView CommandField example
- GridView and DetailsView Master/Detail page using SqlDataSource control
- POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
- Query entity data model using linq to entities
- Difference between arraylist and list collection
- How to create a Web service using Visual Studio.net
- FormView DataBound Event
- Calling base class constructor in C#
- Convert a sequence to a generic list using ToList()method
- Project ideas for students
- Accounting Software
- Creating an ASP.Net MVC 3 application
- Using assemblies in .net applications
- How to implement form validation using ASP.Net 2.0 Validation Controls
- Constructors in Visual Basic.Net