Based-class constructor called when creating instances of a derived class

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.


We are making a Chess game and we need to define the chess piece for the players.

public enum Player 

public class ChessPiece //base class
    public Player Player { get; set; }
    public char Symbol { get; set; }
    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.

9 Replies to “Based-class constructor called when creating instances of a derived class”

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *