explicit-implementation

Is the C# "explicit implementation" of the interface present in Java?

In C#, if you have two base interfaces with the same method (say, F()) you can use explicit implementation to perform different impl. for F(). This alloes you to differently treat the object, corresponding to the current point of view: as IMyInterface1 or IMyInterface2. Is this possible in Java? Thanks ...

Access modifiers on interface members in C#

I am getting a compile error from the following property. The error is: "The modifier 'public' is not valid for this item" public System.Collections.Specialized.StringDictionary IWorkItemControl.Properties { get { return properties; } set { properties = value; } } but if I remove the IWorkItemControl it compiles fine. W...

How to emit explicit interface implementation using reflection.emit?

Dear ladies and sirs. Observe the following simple source code: using System; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; namespace A { public static class Program { private const MethodAttributes ExplicitImplementation = MethodAttributes.Private | MethodAttributes.Virtual | Meth...

C# Language Design: explicit interface implementation of an event

Small question about C# language design :)) If I had an interface like this: interface IFoo { int Value { get; set; } } It's possible to explicitly implement such interface using C# 3.0 auto-implemented properties: sealed class Foo : IFoo { int IFoo.Value { get; set; } } But if I had an event in the interface: interface IFoo ...

Why can't I call methods within a class that explicitly implements an interface?

Here's the story. I created an interface, IVehicle. I explicitly implemented the interface in my class, Vehicle.cs. Here is my interface: Interface IVehicle { int getWheel(); } here is my class: class Vehicle: IVehicle { public int IVehicle.getWheel() { return wheel; } public void printWheel(...

Explicit C# interface implementation of interfaces that inherit from other interfaces

Consider the following three interfaces: interface IBaseInterface { event EventHandler SomeEvent; } interface IInterface1 : IBaseInterface { ... } interface IInterface2 : IBaseInterface { ... } Now consider the following class that implements both IInterface1 and IInterface 2: class Foo : IInterface1, IInterface2 { ...

How can I access an explicitly implemented method using reflection?

Usually, I access a method in reflection like this: class Foo { public void M () { var m = this.GetType ().GetMethod ("M"); m.Invoke(this, new object[] {}); // notice the pun } } However, this fails when M is an explicit implementation: class Foo : SomeBase { void SomeBase.M () { var m = this.GetTy...

C#: Property overriding by specifying the interface explicitly

While attempting to override the explicit interface implementation of the ICollection<T>.IsReadOnly property from the Collection<T> class, I came across some documents stating that explicit interface member implementations cannot be overridden because they cannot have modifiers such as virtual or abstract. On MSDN they even go as far as ...