Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
No Overload takes 5 arguments
Message
De
20/09/2013 12:23:50
 
 
À
20/09/2013 12:03:49
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01583574
Message ID:
01583743
Vues:
38
But that is specifically discussing Framework Design and the reason given is basically "Framework architects designing for a general audience should not expect users to master working with out or ref parameters."

Not sure I agree with that statement but will accept it. However it does not mean, or imply, that there are no valid uses of either 'out' or 'ref' in other contexts.

The .NET TryParse() methods are one example (in which MS ignore their own guidelines :-} )

>I'll argue there's a better way.
>
>From .Net Framework Design Guidelines http://msdn.microsoft.com/en-us/library/ms229015.aspx:
>
>"Out parameters are similar to ref parameters, with some small differences. The parameter is initially considered unassigned and cannot be read in the member body before it is assigned some value. Also, the parameter has to be assigned some value before the member returns.
>
>X AVOID using out or ref parameters.
>
>Using out or ref parameters requires experience with pointers, understanding how value types and reference types differ, and handling methods with multiple return values. Also, the difference between out and ref parameters is not widely understood. Framework architects designing for a general audience should not expect users to master working with out or ref parameters."
>
>Instead of returning out parameters, it may be better to return an object that contains the results.
>
>
>>In that instance - No. But still unnecessary. But if, for example, the parameter is a large object which needs to be marshalled then it is more significant.
>>I'd argue that, just from a best-practice POV, if the called method doesn't require the parameter to be passed in then 'out' is best.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform