.net - How to use attributes and include arguments?
I am writing a class library in VB.Net and one of the sub-sites that are called from an application using my library has more or less the following syntax:
Public Sub LoadDict(ByVal PhoneticType As String, ByVal strDict As String)
where Phonetic type can be phonSoundex, phonDoubleMetaphone or noPhonetic
I want to give a developer app the option to select a PhoneticType from a list when recording a call to the above (I think it's called attribute-arguments). This would make the developer's job easier, as spelling errors could be avoided and it would avoid errors when using the library.
I think it's all about attributes, but I haven't been able to get it to work despite trying.
Anyone can post an example using attributes and including arguments. If the arguments can be made required, that would be even better.
Thanks.
a source to share
If the PhoneticType is limited to a small set of specific values, Enum is probably your best bet.
Enum PhoneticType
phonSoundex
phonDoubleMetaphone
noPhonetic
End Enum
This will help prevent spelling errors from being mentioned, and in addition, an IDE like Visual Studio will provide the developer with intellisense right in the list of valid values.
Public Sub LoadDict(ByVal pt As PhoneticType, ByVal strDict As String)
...
LoadDict(PhoneticType.noPhonetic, False)
a source to share