C
C#ā€¢8mo 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ā€¢8mo 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
Thomoskiā€¢8mo ago
I... hadn't actually thought about that Completely forgot that was even possible
Jimmacle
Jimmacleā€¢8mo ago
there's no rule that says you have to do something with the returned value šŸ˜„
Thomoski
Thomoskiā€¢8mo ago
That's an excellent point, thank you!
Angius
Angiusā€¢8mo ago
Could even explicitly discard it
Accord
Accordā€¢8mo 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
More Posts
ā” Referencing new projects with the main projectLet's say I have a main project `CoreProject` and I want to add 2 new projects: a `LoggerService` anā” Refactoring strategy pattern to a simpler codeI have the following code and I want te refactor it to a less-boiler-plate code. Wha'ts suposed toā” Avoid "Authorizing..." in Blazor Page (Identity)I am trying to avoid the loading text "Authorizing..." when going to my index.razor page. I have addā” Trying to return```csharp using System; using System.Drawing; using System.Windows.Forms; using AForge.Imaging; usinā” Cancel task on nested exceptionI have a series of nested async methods, when a exception is thrown I want to cancel the task. The māœ… Newtonsoft serializing returns nothing with custom converterSo I have a custom `JsonConverter` from newtonsoft that is supposed to replace object properties thaā” 415 error from HttpClient put to a controller using FromBody``` (await _client.PutAsync("foo", new StringContent(5.ToString()))).EnsureSuccessStatusCode(); ``` āœ… Cors not adding headers on ASP.NET applicationI have a asp.net core web app, that will receive calls from a different origin (different port). To ā” IServiceProvider, scoped services, scopesis it correct usage? ```csharp projectA: services.AddScoped<FooContext>(); var serviceProvider = serā” Creating user - TypeError: Failed to fetchHey there! I'm trying to create program, where user can create user with name and password simple. T