Intellisense parameter dropdown for enum parameter, How?

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

How do I get Intellisense to open a dropdown list box for a method's
parameters when the parameter is an ENUM?

public class MyClass
{
public enum IDkind
{
PersonID,
EntityID,
PlaceID
}

/// <summary>
/// Gets an ID value of a particular KIND
/// </summary>
/// <param name="K">The kind of ID desired</param>
public int IDget(IDkind K)
{
return (int) IDsArray.GetValue(new int[] {(int) K});
}
}
===========================

Then, in another location I type:

MyClass.IDkind IDtype = MC.IDget(

When I type the last parenthesis above, Intellisense automatically opens and
shows me the Method's Signature and my parameter's description, like this:

int MyClass.idGet(MyClass.IDkind K)
K: The kind of ID desired

That's fine .... but now I want Intellisense to open a dropdown list of the
valid MyClass.IDkind enum's to choose from.

How?
 
G

Greg Ewing [MVP]

frederick, have you tried typing IDKind. int he method signature? After you
type the Enum name it will give you a drop down of the valid values.
 
S

Scott C. Reynolds

if you are doing this from another class (as I was the other day when i
ran into this), there are two things.

Example 1: Accessing from different class, same namespace

namespace project.namespace1
{
public class MyClass
{
public enum IDkind
{
PersonID,
EntityID,
PlaceID
}

/// <summary>
/// Gets an ID value of a particular KIND
/// </summary>
/// <param name="K">The kind of ID desired</param>
public int IDget(IDkind K)
{
return (int) IDsArray.GetValue(new int[] {(int) K});
}
}
public class OtherClass
{
//here you would reference the enum by
//MyClass.IDKind.PersonID
//tying . after IDKind should pop up the members
}
}

Example 2:
however, if you are going to be referenceing from a different namespace:
namespace someothernamespace
{
public class OtherClass
{
//here you cannot reference the enum by
//MyClass.IDKind.PersonID
}
}
what you would need to do in this case is put the enums you want
accessible OUTSIDE of the class, but inside the namespace
namespace project.namespace1
{
//put enum here
public enum IDkind
{
PersonID,
EntityID,
PlaceID
}
public class MyClass
{
/// <summary>
/// Gets an ID value of a particular KIND
/// </summary>
/// <param name="K">The kind of ID desired</param>
public int IDget(IDkind K)
{
return (int) IDsArray.GetValue(new int[] {(int) K});
}
}
public class OtherClass
{
//now you can just access via the enum name
IDKind.PersonID
//because of shared namespace
//and intellisense will find it.
//and this solves the problem of accessing from another
//namespace as illustrated below
}
}
then in the other namespace,

using project.namespace1
namespace someothernamespace
{
public class someclass
{
//you can just access the enum by name
IDKind.PersonID
//and hitting . will have intellisense bring up the
//members
}
}

hope that helps.
 

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