oop - .NET Best Practice or Framework Example: Function Overload vs. New Method? -
disclaimer: not wish become opinion-based question. looking an example in .net framework library or a .net best practice resolves question.
i designing class , typically caller needs send single foo, on occasion caller need send multiple foos @ once:
edit: there other parameters foo , foo[]. apologies - trying generic.
i have methods (separate methods):
int sendfoo(foo foo, int timeout) int sendfoos(foo[] foos, int timeout)
but thought perhaps should go way (function overload):
int sendfoo(foo foo, int timeout) int sendfoo(foo[] foos, int timeout)
i'm leaning quite heavily toward function overload solution believe i've seen before, proof correct decision.
i cannot recall of similar example in .net framework libraries or if there existing .net best practice scenario.
thank time.
edit in response using params
:
i cannot use params
following reasons:
- sending multiple
foo
objects requires special processing can not bypass. - i using other arguments in method not
foo
type.
examples of overloading:
- string.concat(arg0) / string.concat(args)
- array.createinstance(elementtype, length) / array.createinstance(elementtype, lengths)
examples of using differently named methods:
Comments
Post a Comment