Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you macro in C#/.NET?
Message
From
29/05/2012 12:15:20
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01544610
Message ID:
01544628
Views:
32
I don't totally agree here. While it may be a good idea to check, I don't think you should throw an exception. That should be reserved for special cases or user generated errors. In this case, if the parameter is not passed correctly, it's a developer error. Debug.Assert would be a better choice.

>Dimitry: If the enum value could not be used then an int might be a better choice - but whether a string or an int it would be wise to check that it is a valid value. eg:
           int direction = 1;
>            if (Enum.IsDefined(typeof(ParameterDirection), (ParameterDirection)direction))
>                param.Direction = (ParameterDirection)1;
>            else
>                throw (new InvalidCastException("Invalid ParameterDirection"));
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform