c# - is it better practice to return a complex object or use reference/out parameters? -


I am putting a method that is considered to evaluate the input and if all conditions are found or false Some true test fails, if there is a failure, then I also have some kind of position message available for the caller.

The designs I have come up include the returning of bool and using an out (or ref) parameter for the message, an example of a (specially designed) class bool And returning with string properties or even returning an NM or returning signal or a specific error is returning. What is the best way to get all information from the method? Is any of these "good"? Do anybody have other recommendations?

I usually try to return a complex object and an out parameter when I have to do < / P>

But you see the TryParse methods in NET's conversions, and they follow the pattern of returning a value of the converted values ​​and an external parameter return. Therefore, I do not think it is bad to get the parameter out - it really depends on you what you are trying to do.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -