I have a method that has several "out" parameters. They exit because a value must be set for them inside the function. But in some cases, the compiler is not smart enough, and he does not see that the parameter value is specified in any execution path. Therefore, I have to set default values for outputting parameters at the beginning of the method. But since this method is part of an interface with multiple implementations, this initialization code is duplicated. And I do not like it.
What options do you see to solve this problem? One option that I see is to use ref instead of out. It is not conceptually correct, since it does not guarantee that the parameter value will be set inside the method. But actually it is the same (since I have the default values set at the beginning of the function, which means that in this case it is not guaranteed that the real values are set inside the method).
Any other options?
source
share