You were a good developer and created an enum to represent the integer values that are being passed into your method.
It makes life easy for everyone. Good job.
But now you realize that ANY integer can be passed into your function, even though your type only defines a handful of values.
Well, you need to validate the enum values that are coming into your method.
This can be done quickly with the following code snippet:
If Not [Enum].IsDefined(localId.GetType, localId) Then Throw New System.ComponentModel.InvalidEnumArgumentException("Invalid local value.") End If
In this example localId is the variable name of type LocalType.
Remember Me
Powered by: newtelligence dasBlog 1.9.6264.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts