Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:24+00:00 2026-05-29T04:03:24+00:00

My problem is perhaps pretty simple, but I just started programming in C#. My

  • 0

My problem is perhaps pretty simple, but I just started programming in C#.

My problem is, as listed above: “The type “MyProject.Bike” does not contain a constructor that takes ‘0’ arguments”.

I don’t understand, because I don’t try to make a call to this constructor with empty parentheses, and reading similar questions were all answered with “You have to much/not enough parameters…”.

I just made this for learning, but I think inheritance is a pretty important concept, so I would like to be able to do that…

My code:

using System;  
namespace MijnConsoleProject
{
    public class Bike
    {
        protected int speed = 0;
        public String name
        {
            get;
            set;
        }
        public void speedUp(int increment)
        {
            this.speed += increment;
        }
        public void slowDown(int decrement)
        {
            this.speed -= decrement;
            {

        public override string ToString ()
        {
            return name + ": speed = " + speed;
        }

        public Bike(int initSpeed)
        {
            this.speed = initSpeed;
        }
    }

    public class GearedBike : Bike
    {
        private int gear;

        public GearedBike(string name)
        {
            this.name = name;
        }

        public bool changeGear(int gear)
        {
            if(gear < 8 && gear > 0)
            {
                this.gear = gear;
                return true;
            }
            else
            {
                return false;
            }
        }

        public override string ToString ()
        {
             return name + ": speed=" + speed + ", gear=" +gear;
        }

        public static void main(String[] args)
        {
            Bike fiets = new Bike(10);
            Console.WriteLine("[Normal Bike:]");
            Console.WriteLine("{0}\n", fiets);

            GearedBike fiets2 = new GearedBike("Fiets");
            Console.WriteLine("[Geared Bike:]");
            Console.WriteLine("{0}\n", fiets2);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:03:25+00:00Added an answer on May 29, 2026 at 4:03 am

    Your Bike class only has one constructor:

        public Bike(int initSpeed)
        {
            this.speed = initSpeed;
        }
    

    This takes a single parameter.

    When you derive a class that derived class’ constructor calls a constructor from the base class.

    In your GearedBike class’ constructor you don’t specify which constructor of Bike to call so the compiler assumes Bike(), which doesn’t exist.

    You probably want something like below, where we specify what base constructor to call, and pass in an appropriate value.

        public GearedBike(string name)
            : base(0)
        {
            this.name = name;
        }
    

    You might also want a GearedBike constructor where you can set the speed and name, like below:

        public GearedBike(string name, int initSpeed)
            : base(initSpeed)
        {
            this.name = name;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

simple problem, but perhaps no simple solution, at least I can't think of one
I have a problem which I think is related to forward declarations, but perhaps
Problem: I have two spreadsheets that each serve different purposes but contain one particular
It's a pretty classic problem. The company I work for has numerous business reports
Disclaimer: I'm trying to learn proper OO programming/design, so I'm pretty new to this
This is perhaps a rather silly problem. I have a CheckBox on my page
I'm pretty certain I'm missing something really obvious here but this seems quite bizarre.
I'm just starting to get into backbone.js. It looks like it's pretty involved and
I can run an svn command from the command line but not from within
I've got pretty much the same problem as this guy: http://www.ruby-forum.com/topic/197440 . I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.