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 6328473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:27:52+00:00 2026-05-24T17:27:52+00:00

class StyleProperty<T> { static readonly StyleProperty<Object> INHERIT ; T value; public T Value {

  • 0
    class StyleProperty<T>
{

   static readonly StyleProperty<Object> INHERIT ;

    T value;

    public T Value
    {
        get { return this.value; }
        set { this.value = value; }
    }

}

Hello..
The above class sometimes should have the value INHERIT when value should not be used.. As
c# doesnt allow overloading Properties i cant set Value=StyleProperty.Inherit. i must be of type T.

Any idea what to do there?

  • 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-24T17:27:53+00:00Added an answer on May 24, 2026 at 5:27 pm

    After reading your comments, what about this:

    class StyleProperty<T>
    {
        T _Value;
    
        public StyleProperty(T inheritedValue)
        {
            _Value = inheritedValue;
        }
    
        public T Value
        {
            get { return this._Value; }
            set { this._Value = value; }
        }        
    }
    

    Your first problem is how should the inherited value flow into the concrete instance? The only way i can think of would be the constructor. If the user doesn’t like this value he can simply change it (to maybe the same value).

    If you would use for inheritance some kind of global variable (but that wouldn’t be inheritance, that would be a default value) you could also think about using a boolean flag which will be checked in the getter to find out if the backing store or the default should be used and it will set always to the opposite of its initial state within the setter.

    class StyleProperty<T>
    {
        T _Value;
        bool _UseBackingStore;
    
        public T Value
        {
            get { return _UseBackingStore ? this._Value : INHERIT; }
            set { this._Value = value; _UseBackingStore = true; }
        }        
    }
    

    Update

    To get a skin support into your application i think you need to take a different approach. All forms and gui controls you are using should implement some kind of interface (e.g. ISkin). Also your application should have some kind of SkinSelector. This one holds all informations about coloring, fonts, etc and it also gets a reference to the MainForm. Within the constructor it recursively runs through the Controls property of the form and checks if there are any controls implementing your interface (simply using as ISkin and check for null). If it is skinnable, simply set the colors, fonts, etc. of the control as defined within you SkinSelector. Sounds quite easy but the problem is, that you have to derive all gui controls and add your interface to them. So this is not such a complicated thing, but maybe a lot of work. Maybe you can test if Generics can help you out by using a SkinWrapper<T> where T : Control and an extension function like ISkin ToSkinnableControl(this Control control)). But this will only work if you need to change a few common properties, that are the same for all controls. If you need more skin control e.g. for the DataGridView or a ComboBox i think derivement is the only way to help you out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class MyBase { protected object PropertyOfBase { get; set; } } class MyType :
class Foo { static bool Bar(Stream^ stream); }; class FooWrapper { bool Bar(LPCWSTR szUnicodeString)
class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class
class C { T a; public: C(T a): a(a) {;} }; Is it legal?
class Foo { String bar; // private String bar; } public class A {
class ClassA { public delegate void WriteLog(string msg); private WriteLog m_WriteLogDelegate; public ClassA(WriteLog writelog)
class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple
class A : IFoo { } ... A[] arrayOfA = new A[10]; if(arrayOfA is
class someclass {}; class base { int a; int *pint; someclass objsomeclass; someclass* psomeclass;
class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to

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.