Linked Questions
52 questions linked to/from Calling the base constructor in C#
28
votes
7
answers
23k
views
Calling base constructor in C# [duplicate]
I have the following hierarchy:
class Base
{
public Base(string sMessage)
{
//Do stuff
}
}
class Derived : Base
{
public Derived(string someParams)
{
string sMessage = "Blah " + ...
2
votes
1
answer
10k
views
"There is no argument given that corresponds to the required formal parameter" - when trying to test OOP Inheritance [duplicate]
I'm just trying to understand how Inheritance works in C#. (even though I think I got it, I want to try to do something practical in order to understand)
So I've been trying to create a class with a ...
3
votes
3
answers
2k
views
How to pass base parameters from an overloaded constructor into the derived class [duplicate]
Main
static void Main(string[] args)
{
string name = "Me";
int height = 130;
double weight = 65.5;
BMI patient1 = new BMI();
BMI patient2 = new BMI(name,...
9
votes
1
answer
457
views
Calling a base class constructor in derived class after some code block in derived constructor [duplicate]
public class bar
{
public bar(list<int> id, String x, int size, byte[] bytes)
{
...
}
}
public class Foo: Bar
{
public Foo(list<int> id, String x, someEnumType y):
...
4
votes
1
answer
378
views
Create Exception with a custom constructor in C# [duplicate]
I'd like to create a custom exception with a constructor taking some context and building its message itself. In Java, that would look like (see how to create custom exception with a number in ...
4
votes
1
answer
208
views
c# base key word outside constructor [duplicate]
namespace ClientApp
{
[Service(Exported = false)]
class RegistrationIntentService : IntentService
{
static object locker = new object();
public RegistrationIntentService() ...
2
votes
1
answer
520
views
Why can't I inherit a class in c#? [duplicate]
I am trying to create a basic banking system to practice using classes, after creating the parent class "Account", I tried to create a "savings" class which will be the child class and inherit the ...
0
votes
0
answers
347
views
Is it required to pass the super class parameter for the subclass it is inheriting from? [duplicate]
So I haven been learning Java for a while but decided to switch to C#. It's been a while so I may forget some things. What I know is that in Java, when inheriting from a super class you can or can not ...
4
votes
1
answer
175
views
Having a contructor extend into a sub-class from an abstract class? [duplicate]
I currently have an abstract class such as
abstract class Users
{
private List<string> SelectedUsers;
public Users(List<string> SelectedUsers)
{
this.SelectedUsers = ...
0
votes
1
answer
106
views
How to implement an inherited property in a constructor? [duplicate]
The class Player herits from Deckholder where the property Deck has been declared.
public class Deckholder
{
public Deck Deck { get; set; }
public Deckholder(Deck deck)
{
Deck = ...
0
votes
1
answer
124
views
Inheritance with different properties, how to write? [duplicate]
I have an Animal class with X properties and Tiger class with B properties. The Tiger class inherits from the Animal. When I create an instance of the tiger class, how I put the arguments of the ...
0
votes
0
answers
113
views
How does Monobehaviour from Unity do FixedUpdate() [duplicate]
Im still learning and looking for anyone who can help me out how this works :
For example Unity has FixedUpdate() and Update() most likely ran from a Thread orsomething that tells when to call that ...
-6
votes
2
answers
125
views
BankAccount' does not contain a definition for 'BankAccount [duplicate]
This is bank account class:
namespace BankAccount
{
public abstract class BankAccount
{
protected static int numberOfAccounts = 100001;
private double balance;
private ...
0
votes
0
answers
47
views
C# class instantiation with inheritance [duplicate]
I have a base class 'Description' for loading files describing an object. Its main purpose is to set up a dictionary with entries read out of the file using a reading-loading function from the class-...
0
votes
0
answers
18
views
How to make constructor inheritance not throw errors C# [duplicate]
I'm trying to inherit the constructor of a derived class from a base class but it keeps throwing errors.
public class QueryExecutor
{
private readonly Uri uri;
private readonly string ...