Tuesday, May 22, 2012

Not giving an 'out' argument

It is possible to assign default values to normal arguments to a function, such that



bool SomeFunction(int arg1 = 3, int arg2 = 4)


can be called in any of the following ways.



bool val = SomeFunction();
bool val = SomeFunction(6);
bool val = SomeFunction(6,8);


Is there a way of doing something similar (other than just creating an unused variable) such that



bool SomeOtherFunction(int arg1, out int argOut)


can be called in either of the following ways?



int outarg;
bool val = SomeOtherFunction(4,outarg);
bool val = SomeOtherFunction(4);


Is this at all possible, or if not, what are good workarounds? Thanks.





No comments:

Post a Comment