using enum Type on property

  • Thread starter Thread starter Kevin Auch
  • Start date Start date
K

Kevin Auch

Hi,

I try to declare a property which is an enum type, but i doesn't works, I
get the following message :
"Inconsistent 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
http://www.dotnet-fr.org
----------------------------------------------------------//
 
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
http://www.dotnet-fr.org
----------------------------------------------------------//
Nicholas Paldino said:
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]
- (e-mail address removed)



Kevin Auch said:
Hi,

I try to declare a property which is an enum type, but i doesn't works, I
get the following message :
"Inconsistent 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
http://www.dotnet-fr.org
----------------------------------------------------------//
 
Kevin Auch said:
OK, I know that

You know what? Classic example of how top-posting loses context...
but I hopefully would use the getter & setter.

For what?
So, I know for the enum call "Days" (mine is not really the Days... lol)

If someone knows why it doesn't work ??

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).
 
Back
Top