✅ Default interface methods - Am I using them wrong?
I'm trying to learn when/where to properly use interfaces, and I don't understand why my default method doesn't work.
I have this:
Creating a new instance of
Employee
should give me access to employee.Foo()
, but it doesn't.
Maybe I'm just overlooking something simple, but I don't understand :/6 Replies
I'm using .net6
you can only access DIMs by casting the object to the interface
that being said, you shouldn't use DIMs for this
they were added to the language mostly as a way to add new methods to interfaces in a backwards compatible way
So DIM's are generally not very good practice to use?
they are a tool meant for things like authors of libraries
not so much normal application code
!close
Closed!