C
C#13mo ago
Gipper

❔ How to instantiate derived class when base class requires args?

Hey, I'll post the code below but I don't think it'll be necessary as I'm pretty sure I know what the problem is just not what to do about it...As the title suggests I have a base class that has only one constructor that requires arguments. When I instantiate an object of the derived class I get an error message that seems to be saying it needs the same data in those args of the original base class object: Program.cs(133,16,133,22): error CS7036: There is no argument given that corresponds to the required parameter 'board' of 'Game.Game(Boards, Menu)' Code below as I said, just in case.
6 Replies
Jimmacle
Jimmacle13mo ago
in your derived class's constructor, you have to call the base constructor as an example
public MyDerivedClass(string someArg) : base(someArg) { }
public MyDerivedClass(string someArg) : base(someArg) { }
Gipper
Gipper13mo ago
does this only become a requirement when the base constructor starts requiring args? cause it was working fine before
Jimmacle
Jimmacle13mo ago
technically your derived class's constructor always calls the base class constructor as well, it's only when the only available base constructors have arguments that you have to do it explicitly
Gipper
Gipper13mo ago
thank you the kitty in your pfp is cute btw
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Not sure should I leave the automatic table alteration (postgres EF Core 3.0 to EF Core 6.0)You can see on the picture that EF Core has added some non intentional AlterColumn entries. I guess ❔ Writing VS Extension to Support Language with TextMate Grammar FileHello, I am trying to write extension to support BNF(Backus–Naur form) metalanguage files. I am try❔ Change trigger behavior from code behind(!)Hello again. I am still making a chess game using wpf&wcf. And the problem is that entire board is g❔ Getting SQL data from a relationship tableHello, for my school assignment I have to make a winforms app. Currently I have 3 tables in my SQL D❔ Fast Fourier Transform. I need to make app displaying image and result like ImageJImageJ: https://imagej.net/ij/ So i've chosen to make WPF app because im familiar with it and .NET i❔ ✅ I feel like I've gotten lost in what I'm doing right now, pls help.```cs public async Task DisplayUpdatedTicketsAsync(){ await UpdateTicketsAsync(); DisplayTic❔ How Configure Visual Studio to use webservice SOAP with .p12 certificateLet's see if someone can help me to connect SOAP with .pk certificate using visual studio, I'm alrea❔ About learning C# and Asp.net coreHello guys, i wanna ask something about learning path to web development with c#. I am learning C# ✅ How to fill JObject?I have following: var payload = new JObject{}; I'd like to fill this payload with random data and ❔ Cannot run python processHi I am trying to start the python process by using the Process class in the asp net app hosted in d