C
C#16mo ago
MR1R0B0T

✅ When will we use overload method?

Hello. I would like to ask when do we have to use an overload method? I can't understand despite searching through different platforms for explanation.
8 Replies
Anton
Anton16mo ago
E.g. the Where Linq method has two overloads One that takes a delegate that takes just the item And the second one that takes the item and the index arr.Where(item => item != 5)
MR1R0B0T
MR1R0B0T16mo ago
Also it makes me confused because whenever I look at it they could have the same method invocation name yet they take different parameters so I was wondering instead of overloading that specific method, why not just declare another method?
Anton
Anton16mo ago
vs arr.Where((item, index) => item != 5 && index != 8) it's less mental overload you just call the same method, you don't think about types it's called "static polymorphism"
MR1R0B0T
MR1R0B0T16mo ago
Ahh, I see where you're getting at. Thank you for this explanation. I can already see it. Thank you!
Anton
Anton16mo ago
and it generalizes better to generics or dynamic polymorphism
MR1R0B0T
MR1R0B0T16mo ago
Thank you!
Anton
Anton16mo ago
you're welcome
MR1R0B0T
MR1R0B0T16mo ago
Have a great day ahead
Want results from more Discord servers?
Add your server
More Posts
✅ Results in Console won't give me the values that I need in printing themI would like to ask what's wrong with my code why it won't print the other methods value but instead❔ C# PROGRAM PDF AUTOCOMPLETEHi, I'm a C# developer and I would like to know if you can help me with two specific issues. The fir✅ How to select duplicates on VSI'm new to Visual Studio and I'm trying to do something I can do on VSC. I highlighted something in ❔ Inheritance or object references ? which one is more meaningful```cs public class PetService : BaseEntity { public string Name { get; set; } = string.Empty; ✅ rock paper scissors game```cs // beginner project - rock, paper scissors game using System; using System.Collections.Generi❔ Appease "Property is uninitialized" without setting a default value? Possibly make it required?Hello, I am trying to go through my code and fix all the warnings to improve code quality. I have th✅ creating a wpf appHi, I'm new to wpf and I'm following an older tutorial that says to create a WPF App (.NET Core) pro❔ Index Out of Bounds Exception```cs for (int LinesLeft = LinesOfContent.Length-1; LinesLeft >=0; LinesLeft❔ Handling Supabase auth with dotnet backend. Is this way wrong/not the dotnet way?I'm authenticating users on the frontend using supabase auth. After successful authentication I get ✅ variables declared with/without the “new” keyword.What difference does using the word `new` make in the code? even in terms of memory allocations n st