Oct 25, 2007 #1 djfrear Programmer Joined Jul 11, 2007 Messages 83 Location GB Lets say I have a function: Code: private void MyFunction(String Action) { //code } Now if I wanted "Action" to be a limited list of selections, how would I implement that so it showed up in intellisense? Thanks in advance, Daniel.
Lets say I have a function: Code: private void MyFunction(String Action) { //code } Now if I wanted "Action" to be a limited list of selections, how would I implement that so it showed up in intellisense? Thanks in advance, Daniel.
Oct 25, 2007 1 #2 stsuing Programmer Joined Aug 22, 2001 Messages 596 Location US Use and enum instead of a string Upvote 0 Downvote
Oct 26, 2007 #3 Gorkem Programmer Joined Jun 18, 2002 Messages 259 Location CA You need to have an enum... public enum Actions { Stop = 0, Start = 1, Continue = 2 }; Then, in your function you will have to put: private void MyFunction(Actions action) { //code } This will only allow you to select from one of the selections available in the Actions enum. Cheers, G. Oxigen - Next generation business solutions http://www.oxigen.ca----------------------------- Components/Tools/Forums/Software/Web Services Upvote 0 Downvote
You need to have an enum... public enum Actions { Stop = 0, Start = 1, Continue = 2 }; Then, in your function you will have to put: private void MyFunction(Actions action) { //code } This will only allow you to select from one of the selections available in the Actions enum. Cheers, G. Oxigen - Next generation business solutions http://www.oxigen.ca----------------------------- Components/Tools/Forums/Software/Web Services
Oct 29, 2007 #4 misterstick Programmer Joined Apr 7, 2000 Messages 633 Location GB from the microsoft style guide: http://msdn2.microsoft.com/en-us/library/4x252001(VS.71).aspx Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields. Click to expand... so Actions would be for not mutually exclusive options which can be 'or'ed together. so: Code: public enum Action { Stop = 0, Start = 1, Continue = 2 }; public enum Actions { KillNow = 1, PreserveOptions = 2, LogError = 4 }; mr s. < Upvote 0 Downvote
from the microsoft style guide: http://msdn2.microsoft.com/en-us/library/4x252001(VS.71).aspx Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields. Click to expand... so Actions would be for not mutually exclusive options which can be 'or'ed together. so: Code: public enum Action { Stop = 0, Start = 1, Continue = 2 }; public enum Actions { KillNow = 1, PreserveOptions = 2, LogError = 4 }; mr s. <
Oct 29, 2007 Thread starter #5 djfrear Programmer Joined Jul 11, 2007 Messages 83 Location GB Thanks for all the help, that will do nicely! Upvote 0 Downvote