enums and intellisense

S

Steve Long

Anybody know how to make intellisense show a drop down the list of an enum
as a method argument like it does for .NET types?

Example:

public enum eGroupPlacements
{
GRP_RECORD,
GRP_REPORT
};

private void PlaceGroups(eGroupPlacements egrp)
{
// do something here
}

When I call the PlaceGroups method shouldn't I get a list of all the enum
members in the eGroupPlacements enumeration? How can I make that happen?

Thanks in advance for your help.
Steve
 
Z

Zhanyong Wan [MSFT]

The C# language requires that enum values be qualified by enum types, so
instead of "GRP_RECORD", you will be writing "eGroupPlacements.GRP_RECORD".
Therefore to get intellisense on enum values, you have to write
"eGroupPlacements." first (intellisense can help you write this part too).

This may seem a step backward compared with how it's done in C++, but it
reduces chances for name clashing. For example, you can now have two enum
types to share the same enum value names:

enum Foo
{
Red, Green, Blue
};

enum Bar
{
Red, Black
};

- Zhanyong Wan

Visual Studio and .NET Setup

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included samples (if any) is subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
| From: "Peter Rilling" <[email protected]>
|
| If you are referring to the way VB.NET handles enum parameters, C# does
not
| have this capability. You have to explicitly write the enumeration name
and
| then you get this list of possible values, the list does not appear
| automatically.
|
| | > Anybody know how to make intellisense show a drop down the list of an
enum
| > as a method argument like it does for .NET types?
| >
| > Example:
| >
| > public enum eGroupPlacements
| > {
| > GRP_RECORD,
| > GRP_REPORT
| > };
| >
| > private void PlaceGroups(eGroupPlacements egrp)
| > {
| > // do something here
| > }
| >
| > When I call the PlaceGroups method shouldn't I get a list of all the
enum
| > members in the eGroupPlacements enumeration? How can I make that happen?
| >
| > Thanks in advance for your help.
| > Steve
| >
| >
|
|
|
 

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