TheSean
TheSean

Reputation: 4566

Can I order the enum values in intellisense?

I have an eum type with 5 members. Is it possible to tell intellisense to order them the way I want?

public enum numbers
{
    zero,
    one,
    two,
    three,
    four
}

Intelisense shows (in alpha):

four
one
three
two
zero

Upvotes: 23

Views: 3711

Answers (4)

bobbyalex
bobbyalex

Reputation: 2751

No you cant. But the Visual Studio team has considered the suggestion even though not exactly the way you would want it. But hey, its a start.

You can vote on the link @sepster provided:

https://developercommunity2.visualstudio.com/t/Intellisense-display-enums-by-numeric-or/871057?space=8&entry=suggestion


Edit: Microsoft connect has been retired. Leaving this here for future reference.

See the Microsoft connect response here http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=419602

I have added your requirement as a comment on the site.

Upvotes: 14

Meetu Choudhary
Meetu Choudhary

Reputation: 1355

well if you use this kind of declaration for enum intellisense will sort by the first character

by diffrewnt kind of declartion i mean you can start the enum like _0 _1 _2 like that where _ will have the same previlage and then 0 1 2 etc will be used to reorder it.

Upvotes: 3

Jason Down
Jason Down

Reputation: 22201

I think the only way to do that would be to do something like

public enum numbers
{
    num_00,
    num_01,
    num_02,
    num_03,
    num_04
}

Upvotes: 9

Jamie Ide
Jamie Ide

Reputation: 49301

No you can't as far as I know. Intellisense orders them alphabetically.

Upvotes: 8

Related Questions