In C# OOP, the keyword base can be used to access members of the base class from within a derived class. Regarding the constructor, the keyword base can specify the base-class constructor called when creating instances of a derived class.
Example
We are making a Chess game and we need to define the chess piece for the players.
public enum Player
{
Black,
White
}
public class ChessPiece //base class
{
//Properties
public Player Player { get; set; }
public char Symbol { get; set; }
//Constructor
public ChessPiece(char symbol, Player player)
{
Player = player;
Symbol = symbol;
}
}
The code above is the base class and the following code is a derived class.
public class King: ChessPiece
{
public King(Player player) : base('K', player) {}
}
Class King is a derived class from ChessPiece class. We use keyword base to access the constructor in class King.
Superb, what a website it is! This website gives useful information to us, keep it up.
With havin so much written content do you ever
run into any issues of plagorism or copyright violation? My blog has a lot of exclusive content I’ve either created myself or
outsourced but it appears a lot of it is popping
it up all over the internet without my authorization. Do you know
any ways to help prevent content from being ripped off?
I’d truly appreciate it.
It’s not my first time to pay a visit this web page, i am visiting this web site dailly and take pleasant facts from here everyday.
When some one searches for his vital thing, thus he/she desires to be
available that in detail, thus that thing is
maintained over here.
I am regular visitor, how are you everybody? This post posted at this web page is truly nice.
Good article! We are linking to this particularly great
content on our site. Keep up the great writing.
We are a group of volunteers and starting a
new scheme in our community. Your website offered us with valuable
information to work on. You have done an impressive job and our entire community will
be thankful to you.
When some one searches for his vital thing, therefore
he/she desires to be available that in detail, therefore that thing is maintained over here.
You could certainly see your enthusiasm within the article you write.
The arena hopes for more passionate writers like you who aren’t afraid to mention how they
believe. At all times follow your heart.