© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
12 replies
tornixdev

❔ abstract class vs interface

    public interface IFoo
    {
        protected static string GetFormattedTime() => DateTime.Now.ToString("HH:mm");

        public void Foo();
        public void Bar();
    }

    public class Baz : IFoo
    {
        public void Foo() { ... }
        public void Bar() => Console.Writeline(IFoo.GetFormattedTime())
    }
    public interface IFoo
    {
        protected static string GetFormattedTime() => DateTime.Now.ToString("HH:mm");

        public void Foo();
        public void Bar();
    }

    public class Baz : IFoo
    {
        public void Foo() { ... }
        public void Bar() => Console.Writeline(IFoo.GetFormattedTime())
    }
would an abstract class be appropriate here? or would this be just fine?
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

✅ Abstract Class vs Interface
C#CC# / help
10mo ago
ELI5 : Abstract Class vs Interface
C#CC# / help
2y ago
❔ abstract class virtual methods vs default implementation interface
C#CC# / help
4y ago
Abstract class functions
C#CC# / help
4y ago