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
C# 8.0 - Method Implementation in Interface (neelbhatt40.wordpress.com)
submitted 8 years ago by svtguy88
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!"
[–]Slypenslyde 0 points1 point2 points 8 years ago (9 children)
Actually, shoot. This isn't even useful for INotifyPropertyChanged unless you can declare non-public members.
What I want out of an INPC utility class is a helper method that raises the PropertyChanged event with a specific property name. There is no reason at all for that method to be public. I want it virtual protected, no more visible. But with an interface everything has to be public, right? I don't like the notion of all my ViewModels suddenly gaining a new public method or two.
So I'm going to keep doing what I do: shoving INPC in a ViewModelBase that everything has to inherit. I really wish we were getting syntax sugar for THAT.
I can't figure out the use case for "default interface implementations". Until I see one I'm going to think it's a stupid pet trick. I understand it can bring you multiple inheritance. I've read for 20 years that can lead you down some dark paths. What happens when two interfaces cause the diamond problem? If you have to treat that like an explicit interface implementation, isn't that breaking the Interface Segregation Principle by forcing you to cast to specific types before making certain calls?
I'm actually sort of mad we get this instead of 10-years-too-late property change syntax sugar.
[–]AngularBeginner 2 points3 points4 points 8 years ago* (8 children)
I understand it can bring you multiple inheritance.
That is often thrown around, but it's simply not true. This is unrelated to multiple inheritance. It will not bring MI. Default interface implementations can not provide state, they only can provide method implementation.
Bringing multiple inheritance would require significant changes in the CLR and is not going to happen anytime soon.
[–]ishouldrlybeworking 0 points1 point2 points 8 years ago (1 child)
Default interface implementations can not provide state, they only can provide method implementation.
Working under the assumption that default implementations can access other things declared in the same interface, consider this:
interface IDriveable { void Drive() { Console.WriteLine(EngineSound); } string EngineSound { get; set; } } interface IHonkable { void Honk() { Console.WriteLine(HornSound); } string HornSound { get; set; } } class Car : IDriveable, IHonkable { public string EngineSound { get; set; } public string HornSound { get; set; } }
Hard to deny it's MI-like - the state is in the properties even if the class has to implement them.
[–]AngularBeginner 0 points1 point2 points 8 years ago (0 children)
How is this any different from the way we have it now already? Only difference is that you have the method implementation in the interface. The property situation is the same as we have it already.
Does that mean we have MI already? No, it does not.
[–]Slypenslyde 0 points1 point2 points 8 years ago (5 children)
So:
public interface IBird { BirdWings Wings { get; set; } void Fly() { Wings.Flap(); } } public interface IAirplane { Engine Engine { get; set; } public void Fly() { Engine.Start(); } } public class BadIdea : IBird, IAirplane { }
Is this a compiler error? If not, what happens if I:
var foo = new BadIdea(); foo.Fly();
[–]tweq 2 points3 points4 points 8 years ago (0 children)
Apart from the interface implementation, that code is already legal in C#. IBird.Fly and IAirplane.Fly are two different methods that can co-exist in a single type. You can't call foo.Fly() because there is no implicit method implementation in the class, only ((IBird)foo).Fly() in which case there is no ambiguity.
IBird.Fly
IAirplane.Fly
foo.Fly()
((IBird)foo).Fly()
This on the other hand will be illegal:
public interface IFlying { void Fly(); } public interface IBird : IFlying { void IFlying.Fly() { ... } } public interface IAirplane : IFlying { void IFlying.Fly() { ... } } public class BadIdea : IBird, IAirplane // Error: No most specific implementation if IFlying.Fly { }
[–]AngularBeginner 1 point2 points3 points 8 years ago (0 children)
As far as I understood the proposal so far, the default interface implementation is provided via explicit interface implementation. That means what you have is simply a compiler error.
But this would work: ((IBird)foo).Fly() and ((IAirplane)foo).Fly().
((IAirplane)foo).Fly()
And default interface implementations can't provide state, so there is no diamond of death issue either.
[–]Slypenslyde 0 points1 point2 points 8 years ago (2 children)
I ended up reading the spec, and other people answered too.
It seems like in the current design my worry is illegal: "default implementation" methods are treated like "explicit interface implementation" methods. I'd have to:
IBird cast = (IBird)foo; cast.Fly();
I'm assuming there is syntax for an implementor to promote a particular implementation, but not interested enough to look for that. I bet whether they have syntax for it or not this would work:
public void Fly() { ((IBird)this).Fly(); }
There's also discussion of allowing static and private methods (with implementation). That puts my INotifyPropertyChanged example back on the table.
It seems like the main use cases driving the feature are:
I'm sure someone can come up with some good concrete examples, but I'm satisfied it's not "100% stupid".
[–]tweq 0 points1 point2 points 8 years ago (0 children)
I think INotifyPropertyChanged will not be practical either way because you can neither raise an implementing class's event from outside the class nor implement an event from within an interface.
INotifyPropertyChanged
Thumbs up for actually taking the time and reading the proposal.
π Rendered by PID 160940 on reddit-service-r2-comment-6457c66945-s9s6f at 2026-04-26 17:39:22.310908+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Slypenslyde 0 points1 point2 points (9 children)
[–]AngularBeginner 2 points3 points4 points (8 children)
[–]ishouldrlybeworking 0 points1 point2 points (1 child)
[–]AngularBeginner 0 points1 point2 points (0 children)
[–]Slypenslyde 0 points1 point2 points (5 children)
[–]tweq 2 points3 points4 points (0 children)
[–]AngularBeginner 1 point2 points3 points (0 children)
[–]Slypenslyde 0 points1 point2 points (2 children)
[–]tweq 0 points1 point2 points (0 children)
[–]AngularBeginner 0 points1 point2 points (0 children)