title: C# Asp.Net MVC Inheriting Abstract Class Methods On An Interface
body: <p>I have an abstract class, an interface, and a class that inherits both the abstract class and the interface.</p>
  
  <p>I want to expose the method from the abstract class on the inheriting class. How do I achieve this?</p>
  
  <pre><code>public abstract class CustomerServiceBase
  {
      public string GetName()
      {
          return "John Doe";
      }
  }
  
  public interface ICustomerService
  {
      void DoOtherStuff();
  }
  
  public class CustomerService : CustomerServiceBase, ICustomerService
  {
      public void DoOtherStuff()
      {
          //Code removed for brevity
      }
  }
  
  public class Start
  {
      public void Go()
      {
          ICustomerService _customerService = new CustomerService();
          _customerService.DoOtherStuff();
          var name = _customerService.GetName();//This won't compile
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Apologies, I've added the additional code that accurately shows this scenario, i.e. Using Autofac for dependency injection into an Asp.Net MVC controller, and then using the service class to perform tasks.</p>
  
  <pre><code>public abstract class CustomerServiceBase
  {
      public string GetName()
      {
          return "John Doe";
      }
  }
  
  public interface ICustomerService
  {
      void DoOtherStuff();
  }
  
  public class CustomerService : CustomerServiceBase, ICustomerService
  {
      public void DoOtherStuff()
      {
          //Code removed for brevity
      }
  }
  
  public static class AutofacConfig
  {
      public static IContainer Register(IAppBuilder app)
      {
          var builder = new ContainerBuilder();
  
          ConfigureServices(builder);
  
          var container = builder.Build();
          DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
  
          SetBothDependencyResolvers(container);
  
          return container;
      }
  
      public static void ConfigureServices(ContainerBuilder builder)
      {
          builder.RegisterType&lt;CustomerService&gt;().AsImplementedInterfaces().InstancePerLifetimeScope();
      }
  
  }
  
  public class CustomerController : Controller
  {
      protected readonly ICustomerService _customerService;
  
      public CustomerController(ICustomerService customerService)
      {
          this._customerService = customerService;
      }
  
      public ActionResult Index()
      {
          _customerService.DoOtherStuff();
          var name = _customerService.GetName();
  
          return View();
      }
  }
  </code></pre>
  
  <p><strong>RESULT (based on the accepted answer)</strong></p>
  
  <pre><code>public abstract class CustomerServiceBase : ICustomerService
  {
      public abstract void DoOtherStuff();
  
      //You could mark this as virtual if you want the option to override functionality
      public string GetName()
      {
          return "John Doe";
      }
  }
  
  public interface ICustomerService
  {
      void DoOtherStuff();
      string GetName();
  }
  
  public class CustomerService : CustomerServiceBase
  {
      public override void DoOtherStuff()
      {
          //Code removed for brevity
      }
  }
  
  public class CustomerController : Controller
  {
      protected readonly ICustomerService _customerService;
  
      public CustomerController(ICustomerService customerService)
      {
          this._customerService = customerService;
      }
  
      public ActionResult Index()
      {
          _customerService.DoOtherStuff();
          var name = _customerService.GetName();
  
          return View();
      }
  }
  </code></pre>