using enum Type on property

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Auch

    #1

    using enum Type on property

    Hi,

    I try to declare a property which is an enum type, but i doesn't works, I
    get the following message :
    "Inconsiste nt accessibility: property type 'eType' is less accessible than
    property 'Type' "

    my code :

    enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};

    private Days pJour;

    public Days Jour{
    get{
    return pJour;
    }
    set{
    pJour = value;
    }


    Have U got an idea ??


    Tx

    //----------------------------------------------------------
    Kevin Auch
    CodeWise Community Member
    Votre source d'information quotidienne sur les technologies .NET et l'univers numérique

    ----------------------------------------------------------//


  • Kevin Auch

    #2
    Re: using enum Type on property

    OK, I know that but I hopefully would use the getter & setter.
    So, I know for the enum call "Days" (mine is not really the Days... lol)

    If someone knows why it doesn't work ??

    thx

    --
    //----------------------------------------------------------
    Kevin Auch
    CodeWise Community Member
    Votre source d'information quotidienne sur les technologies .NET et l'univers numérique

    ----------------------------------------------------------//
    "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
    écrit dans le message de news:OgX1w2RUDH A.2520@tk2msftn gp13.phx.gbl...[color=blue]
    > Kevin,
    >
    > Yes, if you are defining this in a class, then by default, the
    > enumeration should be private. Try this declaration:
    >
    > public enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
    >
    > It should work then.
    >
    > Also, you know there is an enumeration titled Day in the
    > System.Windows. Forms namespace, right?
    >
    > Hope this helps.
    >
    >
    > --
    > - Nicholas Paldino [.NET/C# MVP]
    > - nicholas.paldin o@exisconsultin g.com
    >
    >
    >
    > "Kevin Auch" <skevtaz@wanado o.fr> wrote in message
    > news:OIbtXyRUDH A.2196@TK2MSFTN GP12.phx.gbl...[color=green]
    > > Hi,
    > >
    > > I try to declare a property which is an enum type, but i doesn't works,[/color][/color]
    I[color=blue][color=green]
    > > get the following message :
    > > "Inconsiste nt accessibility: property type 'eType' is less accessible[/color][/color]
    than[color=blue][color=green]
    > > property 'Type' "
    > >
    > > my code :
    > >
    > > enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
    > >
    > > private Days pJour;
    > >
    > > public Days Jour{
    > > get{
    > > return pJour;
    > > }
    > > set{
    > > pJour = value;
    > > }
    > >
    > >
    > > Have U got an idea ??
    > >
    > >
    > > Tx
    > >
    > > //----------------------------------------------------------
    > > Kevin Auch
    > > CodeWise Community Member
    > > http://www.dotnet-fr.org
    > > ----------------------------------------------------------//
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • Jon Skeet

      #3
      Re: using enum Type on property

      Kevin Auch <skevtaz@wanado o.fr> wrote:[color=blue]
      > OK, I know that[/color]

      You know what? Classic example of how top-posting loses context...
      [color=blue]
      > but I hopefully would use the getter & setter.[/color]

      For what?
      [color=blue]
      > So, I know for the enum call "Days" (mine is not really the Days... lol)
      >
      > If someone knows why it doesn't work ??[/color]

      It doesn't work for exactly the reason that the compiler gave - your
      enum is private, but your property is public. No caller outside your
      class would be able to understand the return value. You need to either
      make the enum public, or the property private (or both internal, etc).

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      Working...