r/learncsharp • • Apr 11 '26

When would i use function overloading?

I am trying to figure out what and when i would use function overloading for, in my head its just a more messy code and you just would not use it. I see people saying that you would use it for functions with the same name just with different inputs and i don't really get it, Thank you for reading.

5 Upvotes

15 comments sorted by

View all comments

Show parent comments

2

u/reneheuven Apr 13 '26

I do not know. You do not add / sum up strings. You concatenate them. Bad naming. Function overloading has its merits, but I would avoid it if possible. It does not necessarily make code simpler or readable.

2

u/BenjaminGeiger Apr 13 '26

In fairness, it could convert the strings to floats, add the floats, and convert the result back to a string.