© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
42 replies
Kleidukos

❔ Call base method in multiple inheritance

Example of what i have:
public class A
{
  public virtual void Foo()
  {
    Console.Write("Hello ");
  }
}

public class B : A
{
  public override void Foo()
  {
    Console.Write("World");
    base.Foo();
  }
}

public class C : B
{
  public override void Foo()
  {
    Console.Write("!");
    base.Foo();
  }
}
public class A
{
  public virtual void Foo()
  {
    Console.Write("Hello ");
  }
}

public class B : A
{
  public override void Foo()
  {
    Console.Write("World");
    base.Foo();
  }
}

public class C : B
{
  public override void Foo()
  {
    Console.Write("!");
    base.Foo();
  }
}


When i call C#Foo() i get "Hello World!" but i only want to call the base method of A so my console result would be "Hello !"

I hope you guys can understand what i want.
How can i doing this
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ 3 objects inheritance thing + force call base.DoThing();
C#CC# / help
4y ago
✅ Multiple inheritance question
C#CC# / help
3y ago