C# Explicit Interface Implementation when implementing two interfaces, both with the same method and different implementations
Questions tagged [explicit-interface]
88 questions
1
vote
1 answer
How to add new member and override abstract one at the same time?
Let's say you have interface IFoo and some member Member. The class which implements it is capable of implementing the member coming from interface and at the same time adding "new" member with exactly the same name.
It is really great. Now I would…

astrowalker
- 3,123
- 3
- 21
- 40
1
vote
1 answer
LinkedList(T) add-method
The Add-method from the ICollection(T) interface has been explicitly implemented by the LinkedList(T)-class. This collection instead have AddFirst- and AddLast-methods (among others). The explicitly implemented method maps to the AddLast-method.…

Patrik Hägne
- 16,751
- 5
- 52
- 60
1
vote
3 answers
Why is it important which interface method is called?
I am studing interfaces, and at a point I came to explicit interfaces implementation. In a tutorial video at about 2:55 it says that when a class inherits 2 different interfaces, and if those two interfaces has a method with the same name, there is…

HOY
- 1,067
- 10
- 42
- 85
1
vote
0 answers
Linking problems for non explicit interfaces
I am trying to build a model written in F90. I keep having problems with it especially in the linking phase. I tried to compile both with gfortran and with ifort but both of them are complaining about undefined symbols. Here are the errors from…

Manfredo
- 1,760
- 4
- 25
- 53
1
vote
1 answer
How to redefine a property in C# through interface inheritance?
I have an interface 'IBase' that specifies a nullable int. A later interface 'IDerived' hides the nullable int and 'redefines' it as non-nullable.
interface IBase
{
int? Redefineable { get; set; }
}
interface IDerived : IBase
{
new int…

MarkB
- 174
- 14
1
vote
3 answers
Why does RabbitMQ's SimpleRpcServer use an explicit interface implementation for Dispose()?
The class RabbitMQ.Client.MessagePatterns.SimpleRpcServer implements IDisposable using an explicit interface implementation. The implementation is:
void IDisposable.Dispose()
{
Close();
}
That means that in order to call Dispose() on such a…

user2023861
- 8,030
- 9
- 57
- 86
1
vote
3 answers
How do I determine which interface is referenced by an explicitly-implemented MethodInfo object?
I have a MethodInfo object that represents an explicitly-implemented interface method, as follows.
MethodInfo GetMethod()
{
return typeof(List<>).GetMethod(
"System.Collections.IEnumerable.GetEnumerator",
BindingFlags.Instance |…

Steve Guidi
- 19,700
- 9
- 74
- 90
1
vote
1 answer
Interface property fails when defining explicitly
I'm learning about interface properties and ran into something that I thought should work based on MSDN and book examples, but it doesn't. If I implement the interface property explicitly, it's not recognized when my class instance tries to access,…

user943870
- 303
- 2
- 3
- 9
0
votes
2 answers
C# Interface where property shares target class's name, and where property is 'init', cannot assign property in constructor
I have an interface called IHierarchable, intended for both the 'Entity' class and the 'Scene' class which serves as the root of all entities.
///
/// Signifies that an object can exist in the game hierarchy and can have children.
///…

Thomas Slade
- 129
- 9
0
votes
1 answer
Call a class function from an explicit interface function with the same name
The attached code works as expected, it prints 'Something!',
but is it defined behaviour (to call the 'normal' method from the 'explicit' method)?
I have searched for various combinations of 'explicit interface call method/function', but all I could…

Mark Jansen
- 1,491
- 12
- 24
0
votes
0 answers
Explicit interface implementation not working when passing into method with higher interface type
I have a class that contains a list of items (implement IHasItems). In a specific scenario, I want to hide these items by explicit implement IHiddenItems to return empty list.
But there is an existing method (PrintItems - in this case), the input…

Le Vu
- 407
- 3
- 12
0
votes
1 answer
Using an explicit interface for Lapack in Fortran: linking fails looking for a module file
Problem
After adding an external interface for Lapack, the code fails during linking with the message
Undefined symbols for architecture x86_64:
"___msolutionsvd_MOD_dgesvd", referenced from:
___msolutionsvd_MOD_svd_pseudoinverse_solve_sub…

dantopa
- 616
- 7
- 19
0
votes
1 answer
When using Explicit Interface Implementation in Entity classes , EF Core does not creates column in table
public interface IRecordInformation
{
DateTime CreatedOn { get; set; }
DateTime ModifiedOn { get; set; }
}
public class CareerApplication : IRecordInformation
{
public int CareerApplicationId { get; set; }
…

Anuj Chauhan
- 3
- 2
0
votes
1 answer
Exception when querying with an explicit Interface using MongoDB C# driver
I need to construct a query using as a FilterDefinition an explicit Interface but it throws an exception saying :
System.InvalidOperationException
Message={document}.Pointer is not supported.
Source=MongoDB.Driver
I have tried this with normal…

Sebastian Inones
- 1,561
- 1
- 19
- 32
0
votes
0 answers
Is it possible to use an auto property with an explicit interface implementation?
I have an interface that looks like this
public interface IFreezableEntity
{
bool IsFrozen { get; }
void Freeze();
}
And a class that looks something like this:
public class Foo : IFreezableEntity
{
private bool isFrozen;
bool…

Adam G
- 1,283
- 1
- 6
- 15