Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you macro in C#/.NET?
Message
De
30/05/2012 01:44:37
 
 
À
29/05/2012 12:15:20
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01544610
Message ID:
01544729
Vues:
41
Debatable - I don't know enough about Dimitry's situation to have an opinion.
If this module will only be used within Dimitry's app then I'd agree that an Assert would be good.
OTOH if a release version of this was intended for use be other developers then I'd still argue for an Exception....

>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"));
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform