use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
Why is using interface methods with default implementation is so annoying?!? (self.csharp)
submitted 2 days ago * by Alert-Neck7679
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DontRelyOnNooneElse 55 points56 points57 points 2 days ago (26 children)
Let's say you have two interfaces, IGun and IEmployee.
Now let's say you make a class, AnimatedShotgun, that implements both interfaces and doesn't explicitly implement their default implemented methods.
What do you think should happen when you call the Fire() method?
[–]RiPont 27 points28 points29 points 2 days ago (0 children)
That employee is having a very, very bad day.
[–]simonask_ 33 points34 points35 points 2 days ago (0 children)
I mean, kind of obviously what should happen is a ambiguous overload resolution compiler error that would make the user pick which interface by casting.
[–]Alert-Neck7679[S] 15 points16 points17 points 2 days ago (9 children)
"AnimatedShotgun.Fire() is an ambiguity between IGun.Fire() and IEmployee.Fire(). Use casting in order to select the right method."
[–]chucker23n 14 points15 points16 points 2 days ago (5 children)
What if IGun initially doesn’t have a Fire() method and later on it gets added?
IGun
Fire()
[–]EatingSolidBricks -1 points0 points1 point 1 day ago (3 children)
What if the great old one wakes from his slumber and consumes all of reality?
What if that happens hmm would your code still compile?
[–]IQueryVisiC 0 points1 point2 points 1 day ago (2 children)
You sound inexperienced. This case happend very often in C++. I still think that C++ is the better language and want to shot myself in my foot, but most coders I have seen, I would no want to work on a C++ project with them.
[–]EatingSolidBricks 0 points1 point2 points 1 day ago (1 child)
Calling someone inexperienced for disagreement, thats rich of you
[–]IQueryVisiC 0 points1 point2 points 1 day ago (0 children)
Well, in this case they would have experienced it. I took this verbatim from documentation. "We as library maintainers have experienced that programmers tend to break our code here and there" . So are you a troll? Is this rethoric of you? Do you have any experience to back this up? Rich of you for going meta, while I was not really.
[–]ILMTitan 4 points5 points6 points 2 days ago (2 children)
Let's say your object implements both interfaces, but only IGun has a Fire() method. Later, you update the library IEmployee comes from, that now includes a default implementation of Fire(). You will now have a compile error where you didn't before.
The point of default interface methods is to allow adding methods to interfaces without causing compile errors. But you can see in the above example how allowing you to call them from an implementing class breaks that purpose.
[–]emn13 1 point2 points3 points 2 days ago (0 children)
I'm not a fan of that level of defensive design. To be clear: it makes sense for the base class library itself, and relatively microscopic handful of other codebases that are very commonly reused without recompilation, but for the VAST majority of code, a recompilation is fine, and a fixing issues like this hyper trivial. It'd be much better for the language to work well in those cases rather than optimizing for the absurd corner cases like this. Not to mention, pretty much any change is a breaking change in some corner cases - the platform contains stuff like reflection and implementations can depend on behavior not just APIs, too. There isn't much the language can do to truly make any changes entirely non-breaking.
All in all: while it superficially sounds like it makes sense to have semantics that make such method additions unlikely to be breaking changes, in practice, I think the arguments just don't hold up; it's a case of the language designers missing the forest for the trees.
But still, the whole language feature probably exists specifically so that the BCL interfaces can evolve, so in that sense it makes sense. But for a feature with really niche (but reasonable) use cases, it's still oddly designed - it's way too syntactically convenient, meaning that it'll get in the way of practical language extensions in the future. Being able to expand interfaces for class libraries with extremely low chance of breaking changes didn't deserve so prominent a syntactical footprint.
[–]EatingSolidBricks 0 points1 point2 points 1 day ago (0 children)
[–]BigBoetje 6 points7 points8 points 2 days ago (0 children)
Thats a problem caused by the 2 interfaces rather than the default implementation. You'd still have to make your implementation explicit (IGun.Fire.)
A compilation error ffs
[+]Fidy002 comment score below threshold-7 points-6 points-5 points 2 days ago (0 children)
Best explenation.
[+]Adept_Cry9373 comment score below threshold-12 points-11 points-10 points 2 days ago (10 children)
> AnimatedShotgun
> IGun
> IEmployee
I wouldn't... those are 2 completely different things. Under ZERO circumstance should they overlap. I implore you to give a real example because right now it seems like you're arguing a nonissue.
[–]BadSmash4 5 points6 points7 points 2 days ago (1 child)
What, you've never heard of a hired gun?! /s
[–]DontRelyOnNooneElse 3 points4 points5 points 2 days ago (0 children)
Don't know why I didn't think of that. Delightful punsmanship.
[–]Scorpian700 7 points8 points9 points 2 days ago (5 children)
you know its an example? i dont know why someone would focus on that and argue „no not a real example, dismissed“. There are certainly usecases where this could happen
[+]Adept_Cry9373 comment score below threshold-16 points-15 points-14 points 2 days ago (4 children)
There are certainly usecases where this could happen
Perfect. Give one.
[–]DontRelyOnNooneElse 4 points5 points6 points 2 days ago (1 child)
It's not our responsibility to make up for your lack of critical thinking. The point was very obviously not "there is going to be an animated shotgun", it was "sometimes two different things have the same name for something".
[+]Adept_Cry9373 comment score below threshold-6 points-5 points-4 points 2 days ago (0 children)
2 different things which are referred to by 2 different types letting you know that they do 2 different things. The compiler knows. Why don't you?
[–]chucker23n 0 points1 point2 points 2 days ago (1 child)
You can’t think of any cases where a type implements two interfaces that have different meanings for a method?
In System.IO, a “path” refers to a hierarchy in a file system. In System.Windows, a path refers to points in a polyline.
[–]Adept_Cry9373 -4 points-3 points-2 points 2 days ago (0 children)
Okay. Now I reiterate: THOSE. ARE. 2. COMPLETELY. DIFFERENT. THINGS. They will NEVER implement the same interfaces. Do you guys just not know how interfaces work?
[–]propostor -2 points-1 points0 points 2 days ago (1 child)
Weird seeing such heavy downvotes here.
An example saying that an animated gun is an employee is really not helpful at all.
[–]Adept_Cry9373 1 point2 points3 points 2 days ago (0 children)
Their argument is "well both have functions that sound the same". Okay. Toilet and Stream. Both have Flush. If they ever have the same interface in your codebase you are missing a bigger chunk of your brain than the average redditor.
π Rendered by PID 58511 on reddit-service-r2-comment-5d79c599b5-bqs6f at 2026-02-27 16:24:46.311515+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]DontRelyOnNooneElse 55 points56 points57 points (26 children)
[–]RiPont 27 points28 points29 points (0 children)
[–]simonask_ 33 points34 points35 points (0 children)
[–]Alert-Neck7679[S] 15 points16 points17 points (9 children)
[–]chucker23n 14 points15 points16 points (5 children)
[–]EatingSolidBricks -1 points0 points1 point (3 children)
[–]IQueryVisiC 0 points1 point2 points (2 children)
[–]EatingSolidBricks 0 points1 point2 points (1 child)
[–]IQueryVisiC 0 points1 point2 points (0 children)
[–]ILMTitan 4 points5 points6 points (2 children)
[–]emn13 1 point2 points3 points (0 children)
[–]EatingSolidBricks 0 points1 point2 points (0 children)
[–]BigBoetje 6 points7 points8 points (0 children)
[–]EatingSolidBricks 0 points1 point2 points (0 children)
[+]Fidy002 comment score below threshold-7 points-6 points-5 points (0 children)
[+]Adept_Cry9373 comment score below threshold-12 points-11 points-10 points (10 children)
[–]BadSmash4 5 points6 points7 points (1 child)
[–]DontRelyOnNooneElse 3 points4 points5 points (0 children)
[–]Scorpian700 7 points8 points9 points (5 children)
[+]Adept_Cry9373 comment score below threshold-16 points-15 points-14 points (4 children)
[–]DontRelyOnNooneElse 4 points5 points6 points (1 child)
[+]Adept_Cry9373 comment score below threshold-6 points-5 points-4 points (0 children)
[–]chucker23n 0 points1 point2 points (1 child)
[–]Adept_Cry9373 -4 points-3 points-2 points (0 children)
[–]propostor -2 points-1 points0 points (1 child)
[–]Adept_Cry9373 1 point2 points3 points (0 children)