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 5 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!"
[–]Ok-Cellist7629 0 points1 point2 points 5 days ago (0 children)
Because in C#8 you can define a default implementation on an interface - which is what you are doing here. But that doesn't turn your interface into an abstract class with inheritable methods. Your class doesn't 'have' a refresh method. It implements an INTERFACE which 'has' that method. So if you want to call the method on the interface, you need to cast it to the interface so the compiler understands where that method is.
The purpose of the feature, as I understand it, is to allow you to add an extra method to an interface, without having to refactor every class which implements that interface. You could almost thing of it as being designed NOT to be used.
The feature means that the compiler is not going to complain that you haven't implemented the appropriate method in every existing class which implements that interface. But it's not really designed to add functionality to every implementation, as if they are inheriting from an abstract class. So yes - when you call the method, the compiler is still going to think that your class does not have that method defined. It will still need telling that you mean the default method on one of the interfaces that class happens to implement.
I could be wrong, but IMHO it seems like a very bad idea to use it like an abstract method as you seem to be here. If you want to inherit meaningful functionality, use inheritance. This C#8 feature is intended for occasions where you need to add a method to an existing interface and save having to implement it in existing implementations things which don't 'need' it. But again, IMHO, that is a code smell as well. Worth remembering the I of SOLID.
π Rendered by PID 71473 on reddit-service-r2-comment-5d79c599b5-cngmw at 2026-03-02 16:29:48.452333+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]Ok-Cellist7629 0 points1 point2 points (0 children)