Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Different level of accessors for class and enum

I need to keep my enumeration internal and I need to keep my class style public. How to handle in this situation?

public class Style : VisionItem, BaseItem
{
    public string TargetType { get; set; }
    public string FontFamily { get; set; }
    public int FontSize { get; set; }
    public StyleType Type { get; set; }
}

internal enum StyleType
{
    TextCss,
    TextJs
}

I received such error: Inconsistent accessibility: property type ‘StyleType’ is less accessible than property ‘Style.Type’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The type Style can be public, but external code can’t see the Type property. eg

public class Style : VisionItem, BaseItem
{
    public string TargetType { get; set; }
    public string FontFamily { get; set; }
    public int FontSize { get; set; }
    internal StyleType Type { get; set; }
}

internal enum StyleType
{
    TextCss,
    TextJs
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading