interface

Can I make a .NET framework class implement an interface that I define?

I want to take a .NET class (let's say FileInfo for the sake of discussion) and have it implement my interface. For example: public interface IDeletable { void Delete(); } Note that the FileInfo DOES have the Delete() method, so this interface could make sense. So that I can have code like this: FileInfo fileinfo = ...; DeletOb...

C# Generic Copy Constructor

I have an interface, and two classes that implements the interface. The classes have generic types. I would like to clone from an instance of one class to the other. interface IFoo { // stuff } class Foo<T> : IFoo { // foo stuff // ifoo implementation } class Bar<T> : IFoo { // bar stuff // ifoo implementation } ...

In Java when one interface extends another, why would one redeclare a method in a subinterface?

I've been looking at the JMS API from J2EE and found a strange behavior where certain methods that are declared in an interface (e.g., createQueue in Session) are declared again in the subinterfaces such as QueueSession, and with identical documentation. Since an subinterface "inherits" all the method declarations of the interface it in...

When are interfaces needed?

(In the context of .NET for what its worth) I tend to not use inheritance and rarely use interfaces. I came across someone who thinks interfaces are the best thing since spit. He uses them everywhere. I don't understand this and hence the questions that follow. I just want a check on my understanding of interfaces. If you are using...

Is a Ruby module equivalent to a Java Interface?

As I understand it, an interface is Java is intended to enforce a design by laying out methods for classes implementing the interface to fill in. Is this the idea with a Ruby module also? I see that just like with Interfaces in Java, you can't instantiate a module in Ruby. ...

microsoft C# .net Interface doubts

How can an access specifier to the member of interface be specified? We can use interface as in two ways Inheritance ( IsA relation ) Containment in another class (Has A relation). In this way of implementation protected access specifier is applied only to the events which are in inheritance relationship (IsA). public access spec...

Is there a way to force a C# class to implement certain static functions?

I am developing a set of classes that implement a common interface. A consumer of my library shall expect each of these classes to implement a certain set of static functions. Is there anyway that I can decorate these class so that the compiler will catch the case where one of the functions is not implemented. I know it will eventually ...

Binding a module's interface requirement either at run-time or compile/link time, which is better?

Hello, I have a question or best approach of connecting interface either during run-time or compile/link time. For my embedded projects the device drivers and I/O have interfaces that need to be bound (i.e. glued) to their corresponding interface dependencies. For example, for the analog device driver it requires an interface to the dis...

C# .NET passing a collection of InterfaceImplementingClass objects to a routine that takes a collection of Interface objects

I have a routine public void SomeRoutine(List<IFormattable> list) { ... } I then try to call this routine List<Guid>list = new List<Guid>(); list.Add(Guid.NewGuid()); SomeRoutine(list); And it fails with a compile-time error. System.Guid implements IFormattable, but the error I get is cannot convert from 'System.Collections....

Breaking an interface

What are the most important guidelines to follow if you need to break an interface in a .NET application? How do these guidelines change before and after your application has been deployed? I know there are other questions that debate when/where interfaces should be used, however I don't want to get into that. I just want to know some ...

What's the use of attributes on an interface?

Duplicate of can a c class inherit attributes from its interface Using Resharper, I extracted an interface of an existing class. This class has some attributes set on a few members, and Resharper also put these on the interface members. Can I delete these attributes from the interface? Attributes on an interface aren't inherited when i...

WCF Service - runtime not seeing the ServiceContract on Interface

I'm new to WCF and trying to get my first service running. I'm close but stuck on this problem. In my interface definition file, I have this: [ServiceContract(Namespace="http://mysite.com/wcfservices/2009/02")] public interface IInventoryService { [OperationContract] string GetInventoryName(int InventoryI...

wpf outlook-like interface

Hello, Can anyone point me to a tutorial on how to create an outlook like interface in WPF? Thanks ...

Practical side of the ability to define a class within an interface in Java?

What would be the practical side of the ability to define a class within an interface in Java: interface IFoo { class Bar { void foobar () { System.out.println("foobaring..."); } } } ...

Difference between generic argument constrained to an interface and just using the interface

What is the difference between this: void MyMethod(IMyInterface value) { //... } and this: void MyMethod<T>(T value) where T : IMyInterface { //... } ...

C# interface question

Is there a cost in passing an object to a function that implements a particular interface where the function only accepts that interface? Like: Change (IEnumerable<T> collection) and I pass: List<T> LinkedList<T> CustomCollection<T> which all of them implements IEnumerable. But when you pass any of those to the Change method, are t...

implicit vs explicit interface implementation

Would someone explain the differences between these two beasts and how to use them. AFAIK, many pre.2.0 classes were implemented without generic types, thus causing latter version to implement both flavors of interfaces. Is the the only case why one would need to use them? Can you also explain in depth how to use them.? Thanks ...

weird C# compiler error: cyclic inheritance

I came across the following error a few days ago, in one of our C# applications here at work. Here's how the error message looks like: "Inherited interface '...ResourceManager.ResourcesManager' causes a cycle in the interface hierarchy of '...ResourceManager.IResourcesManagerView' in D:...\Common\ResourceManager\IResourcesManagerView.cs...

Unexpected behaviour of inheritance and interfaces in c#

Today, while implementing some testclasses in c#, I stumpled on some questions regarding inheritance (and interfaces) in c#. Below I have some example code to illustrate my questions. interface ILuftfahrzeug { void Starten(); } class Flugzeug : ILuftfahrzeug { public void Starten() { Console.WriteLine("Das Flugzeug ...

Object Oriented Analysis and Design

Why I can't able to specify static type of methods in interface. Is there any alternative to do this?? but I should use only inerface insted of abstract class. / Is there any problem in specifing acess specifier in interface? I want to specify the events in Interface and that should be acessed only by implemented class so i want pr...