© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
28 replies
Tofaa

Have public static values accessible thru the class that inherited this class

I understand the title is rather silly but i couldnt word it properly to fit a title. I come from a java background, and am currently making something where i require an exposed api interface and also code-generated values inside the interface. For clutter reasons I'd like to seperate the interface and the static methods. In java for example

public sealed interface A extends VariousAs { 
}

class AImpl {}

interface VariousAs {
    
    A VALUE_ONE = new AImpl();
    A VALUE_TWO = new AImpl();
}
public sealed interface A extends VariousAs { 
}

class AImpl {}

interface VariousAs {
    
    A VALUE_ONE = new AImpl();
    A VALUE_TWO = new AImpl();
}


In the code above i can easily access A.VALUE_ONE without exposing AImpl and VariousAs, but theres no way (atleast from what i can tell) to replicate such behaviour in c#.
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

❔ ✅ public class
C#CC# / help
4y ago
❔ static class
C#CC# / help
3y ago