C
C#ā€¢14mo ago
Thomoski

Is there a better (or more appropriate way) of implementing method overloading for my usecase here?

I have two methods of a class I'm writing - in one usecase I want to update the field with no return value and in the other, I want to return the new value after it's been updated with the provided parameter. My current implementation doesn't raise any warnings, but VS does recommend that I remove unused parameters, so wondering if there's a feature or technique I could use to achieve the same effect
No description
6 Replies
Jimmacle
Jimmacleā€¢14mo ago
i'm not sure what you're going for why not just have one method that always returns the new value, and ignore it if you don't need to use it?
Thomoski
ThomoskiOPā€¢14mo ago
I... hadn't actually thought about that Completely forgot that was even possible
Jimmacle
Jimmacleā€¢14mo ago
there's no rule that says you have to do something with the returned value šŸ˜„
Thomoski
ThomoskiOPā€¢14mo ago
That's an excellent point, thank you!
Angius
Angiusā€¢14mo ago
Could even explicitly discard it
Accord
Accordā€¢14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server