??????,
This won't work. The enumeration is defined as private, and has no
scope outside of the class that it is defined in. Because the constructor
is public, you can't expose a private type to the class as a parameter.
Instead, you have to declare the enumeration as public, like so:
class Student
{
private string name;
public enum university {.....};
Also, you might want to consider declaring your enumeration outside of
your class. It's more of a design issue. The decision to do so would
depend on what the enumeration represents. If the enumeration is specific
to that class, then its fine where it is, but if it is really something that
is not specific to the class, you should define it outside of the class.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"??????" <@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.com...
>I want to use an enum field in a constructor.
For example:
class Student
{
private string name;
private enum university {.....};
private byte course;
......
public Student ( string name, enum university)
{
.........
}
I'm fairly new to programming so any sample code would be most
appreciated.
}