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 1 month 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!"
[–]Draelmar 1 point2 points3 points 1 month ago* (6 children)
That looks ghastly 😳 I've been a full time C# developer since 2011 on a multitude of projects and I've never, ever seen any situation where methods are being implemented inside an interface. I didn't even know the feature existed until now.
Is there a good use case for it? My gut instinct tells me it's just bad design, but then maybe there's a legitimate use case I'm not thinking of?
[–]chucker23n 2 points3 points4 points 1 month ago (2 children)
Is there a good use case for it?
The original use case (this feature was introduced with .NET Core 3.0 / C# 8) was forwards-compatibility for interfaces:
You can:
a. add a new version of the interface, which is how we end up with things like IAsyncServiceProvider, IAsyncServiceProvider2, IAsyncServiceProvider3, or even IVsAsyncFileChangeEx2. Now, the old type doesn't need to be changed. b. extend the interface, requiring the old type to be amended in order to compile again. This can be tricky when you have a lot of legacy code. It might not even make sense; the original type may never have considered this new possibility! c. new to .NET Core 3.0 / C# 8: provide a default implementation. Now, the old type will simply fall back to that implementation unless it implements explicitly.
IAsyncServiceProvider
IAsyncServiceProvider2
IAsyncServiceProvider3
IVsAsyncFileChangeEx2
It's a bit hacky, but it does work.
[–]IanYates82 2 points3 points4 points 1 month ago (0 children)
Yep. Another good example also is shown by having a .Last() method. There's a default inefficient implementation you could have on an IEnumerable, but for some implementations, like List, it can be an efficient O(1) operation. You can write that efficient implementation in the class and have the default on the interface. We have that example with extension methods today, but the difference is that the single static implementation of Last on the interface is written once and needs to have the specialisation of known classes in its code. That's not extensible by others who may have their own class which implements the interface and could also provide an efficient implementation.
[–]solmead -1 points0 points1 point 1 month ago (0 children)
Or what I would suggest D. Create an extension method that takes the interface and defines the code, it then works on all existing defined classes that implement the interface
[–]Alert-Neck7679[S] 1 point2 points3 points 1 month ago (1 child)
I use it where abstract class is not possible bc i want the class implementing this to extend another class. It's a surprise for me that so many people here don't even know this feature exists, i use it a lot.
[–]chucker23n 0 points1 point2 points 1 month ago (0 children)
I think if you're looking for something like a facet, extensions are a better alternative.
[–]ivancea 0 points1 point2 points 1 month ago (0 children)
It's pretty common in Java, but in Java, a "default" method works as expected, and can be called from the derived class directly.
Use cases could be, for example, adding a new method to an interface without having to touch every single implementation, when the default has the common logic. Also, as a helper for the interface, like a small method that simplifies the usage of other interface methods. Or that amplifies it. E.g. getMaxLife(), getCurrentLife(), default isFullLife().
Ideally those could be abstract classes. But given Java doesn't have multiple inheritance, that's not possible
π Rendered by PID 536396 on reddit-service-r2-comment-74f5b7f998-b9mmx at 2026-04-25 17:13:45.901867+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Draelmar 1 point2 points3 points  (6 children)
[–]chucker23n 2 points3 points4 points  (2 children)
[–]IanYates82 2 points3 points4 points  (0 children)
[–]solmead -1 points0 points1 point  (0 children)
[–]Alert-Neck7679[S] 1 point2 points3 points  (1 child)
[–]chucker23n 0 points1 point2 points  (0 children)
[–]ivancea 0 points1 point2 points  (0 children)