Answers for "c# call base constructor"

C#
2

c# call base constructor

public class MyExceptionClass : Exception
{
    public MyExceptionClass(string message, string extrainfo) : base(message)
    {
        //other stuff here
    }
}
Posted by: Guest on December-03-2020
2

c# superclass constructor

// Create Constructor in superclass
public Vehicle( double speed )
    {
      Speed = speed;
      LicensePlate = Tools.GenerateLicensePlate();
    }

//Original Constructor
class Sedan
  {
    public Sedan(double speed)
    {
      Speed = speed;
      LicensePlate = Tools.GenerateLicensePlate();
      Wheels = 4;
    }

// Remove 'Speed' and 'LicensePlate' from Sedan Constructor
// Add 'class Sedan : Vehicle '
// Add 'public Sedan(double speed) : base(speed)'
  
//New Constructor
class Sedan : Vehicle
  {
    public Sedan(double speed) : base(speed)
    {
      Wheels = 4;
    }
  }
Posted by: Guest on March-05-2020

C# Answers by Framework

Browse Popular Code Answers by Language