using enum Type on property

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
----------------------------------------------------------//
 
K

Kevin Auch

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
----------------------------------------------------------//
 
J

Jon Skeet

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top