Questions tagged [interface-implementation]

137 questions
86
votes
5 answers

What interfaces do all arrays implement in C#?

As a new .NET 3.5 programmer, I started to learn LINQ and I found something pretty basic that I haven't noticed before: The book claims every array implements IEnumerable (obviously, otherwise we couldn't use LINQ to objects on arrays...). When I…
ET.
  • 1,899
  • 2
  • 18
  • 28
72
votes
6 answers

How do you quickly find the implementation(s) of an interface's method?

Is there a quick way to find all of the implementations of, not references to, an interface's method/property/etc? Here's some sample code: public class SomeClass : IBaseClass { public Int32 GetInt() { return 1; } } public interface…
Beep beep
  • 18,873
  • 12
  • 63
  • 78
26
votes
6 answers

How many interfaces are allowed to be implemented?

In C#: How many interfaces a class can implement at the same time? public class MyClass: IInteferface_1, IInterface_2, ... , IInterface_N { } Is there a limit for N? Don't worry I don't want to implement or maintain such an object. I was just…
Liviu Mandras
  • 6,540
  • 2
  • 41
  • 65
21
votes
3 answers

Interface implemented twice "types may unify"; why does this workaround work?

I've run into a compiler error when attempting to implement an interface twice for the same class like so: public class Mapper : IMapper, IMapper { /* implementation for IMapper here. */ /* implementation for…
fooser
  • 822
  • 6
  • 14
20
votes
1 answer

Unexpected behavior of a C# 8.0 default interface member

Consider the following code: interface I { string M1() => "I.M1"; string M2() => "I.M2"; } abstract class A : I {} class C : A { public string M1() => "C.M1"; public virtual string M2() => "C.M2"; } class Program { static void…
13
votes
0 answers

Two parameters causes 'Method in Type does not have an implementation' Exception?

I have an solution with a number of projects. Relevant for the question is an API class library, a CustomTriggers class library and a web site. Both CustomTriggers and web site references API. CustomTriggers implements Interface ITrigger located in…
volapture
  • 131
  • 1
  • 1
  • 4
13
votes
4 answers

Does libxml2 support XPath 2.0 or not?

I've tried to use the XPath 2.0 exp //span/string(.) in libxml2, but it doesn't work. So, my question is: does libxml2 support XPath 2.0 or not?
13
votes
2 answers

In C#, is it possible to implement an interface member using a member with a different name, like you can do in VB.NET?

Ok, this is a question I'm asking, not as in demonstrating good coding practices (this actually could be considered a bad practice) but rather in regards to 'can' it be done at all. That said, in VB.NET you implement an interface like this... Sub…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
13
votes
2 answers

Choose a concrete implementation at runtime with Java 8

I'm not clear about where to put the if/switch when choosing what implementation/subclass to instantiate, specially when considering that now interfaces can have static methods. Let's say I have a service, a type defined by an interface and a couple…
user3748908
  • 885
  • 2
  • 9
  • 26
12
votes
2 answers

PHP interface implementation rejects subclasses on parameters

consider this: class A{} class B extends A{} interface I{ // expects object instanceof A function doSomething(A $a); } class C implements I { // fails ???? function doSomething(B $b){} } In my conception the above should work but it doesn't…
fabio
  • 2,269
  • 5
  • 22
  • 34
12
votes
2 answers

What are the API that does implement JSR-353 (JSON)

I just found out that Jackson does not implement JSR-353 and we already designed the module.. so i am in a desperate hurry to find a replacement of this API to begin working ! :D I searched an API that implements the standard but could not find any…
maher.belkh
  • 473
  • 2
  • 7
  • 21
11
votes
4 answers

Can a class extend the Collection object?

I'm trying to extend functionality of the VBA Collection object in a new class and make this class an inheritant of Collection, but the Implements Collection statement gives me the following error: Bad interface for Implements: method has…
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
11
votes
3 answers

How to create a custom observable collection using ConcurrentDictionary, INotifyCollectionChanged, INotifyPropertyChanged

I am trying to create an ObservableConcurrentDictionary. This object will be used in a multithreaded application, and it's data is used to populate a control via the controls ItemsSource property. This is the implementation i have come up…
11
votes
5 answers

Avoid explicit type casting when overriding inherited methods

I have a base abstract class that also implements a particular interface. public interface IMovable where TEntity: class where T: struct { TEntity Move(IMover moverProvider); } public abstract class Animal :…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
11
votes
3 answers

in MVC4 shows and error that I have to implement some Interface but I am already done it

I am trying to create own filter attribute in order to support multilinguality. The idea is simple. URL stands for language. *http://host.ext/en/rest_of_the_url* will open in English and *http://host.ext/hy/rest_of_the_url* will open in…
1
2 3
9 10