Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6961953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:35:51+00:00 2026-05-27T15:35:51+00:00

I have been thinking the design over for a couple days now and I’m

  • 0

I have been thinking the design over for a couple days now and I’m asymptotically 100% sure this is a design problem. However, here’s my predicament: I essentially want to have a compiler checked and polymorphic static classes. Specifically, I have this:

static class TileSettings
{
    static class TileOne
    {
        public const TileType TYPE = TileType.TileOne;
    }

    static class TileTwo
    {
        public const TileType TYPE = TileType.TileTwo;
    }
}

This seems fine but I would like to have the subclasses to follow a contract (like an interface) that TileOne and TileTwo could follow so that somewhere in code I could do something like the following:

public void function(TileSettings SETTINGS_TO_USE)
{
    someLocalVariable = SETTINGS_TO_USE.TYPE;
}

function(TileOne);
function(TileTwo);

One major problem that sticks out to me though is that one can’t pass a static class into a function. What I could do is have a static class with methods that take a TileType and use a switch to return that types value. That seems like it would be highly inefficient, however, if it ends up being called a lot. So, any thoughts? Is there something simple I’m unaware of that would solve this? Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:35:51+00:00Added an answer on May 27, 2026 at 3:35 pm

    Yes, the answer is: don’t use a static class.

    How about this:

    class TileSettings
    {
        public readonly TileType TYPE;
    
        public static readonly TileSettings TileOne = new TileSettings(TileType.TileOne);
        public static readonly TileSettings TileTwo = new TileSettings(TileType.TileTwo);
    
        public TileSettings(TileType type)
        {
             TYPE = type;
        }
    }
    

    You can use it like this then:

    public void function(TileSettings settings)
    {
        someLocalVariable = settings;
    }
    
    function(TileSettings.TileOne);
    function(TileSettings.TileTwo);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been thinking about this object oriented design question for a while now and
I have been thinking about a way solve a problem I have and I'm
Have been working on this question for a couple hours and have come close
I've been designing a site over the past couple days, and been doing some
I have been thinking about database design lately and I have the following question:
I have been thinking about design by contract lately and I was wondering what
I have been thinking for a good while about how to tackle the problem
I have been thinking of a way to export data from SQL to Excel.
I have been thinking of starting a site of my own for long time.
I have been thinking about the optimal way to create an XML file using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.