I'm sure you can use them where you want to define a common framework for a datatype but allow for different implementations of that datatype. For example if you created a LookupTable interface with various methods for adding to the table and searching it, but didn't want to specify in advance how it was going to be implemented.
My point above about the code you gave me was that if you did that you would end up having to use LinkedList in every class that implemented the interface. I'll try and give you an example of what I mean but I don't promise it'll be understandable:
I don't know if you can understand from that what I'm trying to say, but meh.Code:public interface IMyClass { MyClass aDataMember // what I thought should be here is IMyClass, but alas, no { get; set; } } public class MyClass : IMyClass { MyClass aDataMember { ... } } but you would also have the following if you tried to create another class implementing the interface: public class MyOtherClass : IMyClass { MyClass aDataMember // what I really want here is MyOtherClass { ... } }
I know I can do that, but I didn't want to because it looks a bit illogical since you would expect that you could substitute LinkedListNode for ILinkedListNode anywhere in any case.ILinkedListNode node = new LinkedListNode(27);
ac




Reply With Quote