I understand how the "new" keyword can hide methods in a derived class. However, what implications does it have for classes that implement interfaces that use the keyword?
Consider this example, where I decide to expand an interface by making its properties read/write.
public interface IReadOnly {
string Id {
get;
}
}
pub...
I'm probably missing something very basic but I cannot figure out why I get a compilation error with a certain code and I don't get it in an almost identical code.
So I do get an error here:
//parent.GetChildren() returns a IEnumerable<IBase>
F1<T>(T parent, Func<string, T, string> func) where T: IBase
{
F1(parent.GetChildren(), ...
Inherited property (P1) is not accessable from w/cscript.
Class structure looks something like this :
[ComVisible]
public interface IA
{
string P1{get;}
}
[ComVisible]
public interface IB : IA
{
string P2{get;}
}
[ComVisible]
public abstract class Base : IA
{
public string P1{get{return "somestring";}}
}
[ComVis...
The following pseudocode works, which is probably no surprise to anyone who's done any JDBC work:
ResultSet rs = foo.executeQuery();
boolean hasNext = rs.next();
while(hasNext) {
bar();
boolean hasNext = rs.next();
}
ResultSet (java.sql.ResultSet) is an interface, so there should be no implementation for next(), only a method ...
I am putting together some mock-ups of my first real interface and I am left wondering: What are some basic tenets of good user interface design? I am looking for something like a bullet list summary and maybe some resources that might be useful for each tenet.
...
Is it possible to inject an interface into an existing 3rd party class that I can not alter? Like extension methods but for an interface (and its implementation for the class that it had been injected to).
I like to optionally use one of two similar 3rd party libraries by giving classes that are similar in both libraries the same interf...
Having this code...
var b = new ReadOnlyCollection<int>(new[] { 2, 4, 2, 2 });
b[2] = 3;
I get a compile error at the second line. I would expect a runtime error since ReadOnlyCollection<T> implements IList<T> and the this[T] have a setter in the IList<T> interface.
I've tried to replicate the functionality of ReadOnlyCollection, bu...
I'm writing an interface and I want to declare a property that returns a generic collection. The elements of the collection should implement an interface. Is this possible and, if so, what is the syntax.
This doesn't compile, what's the right way to do this?
interface IHouse
{
IEnumerable<T> Bedrooms { get; } where T : IRoom
}
Th...
Hi. I have been messing around with iTunes COM from python.
However, I haven't been able to access the Lyrics of any track.
I have been using python for this. Here is the code:
>>> import win32com.client
>>> itunes = win32com.client.Dispatch("iTunes.Application")
>>> lib = itunes.LibraryPlaylist
>>> tracks = lib.Tracks
>>> tracks
<win...
I keep hearing the statement on most programming related sites:
Program to an interface and not to an
Implementation
However I don't understand the implications?
Examples would help.
EDIT: I have received a lot of good answers even so could you'll supplement it with some snippets of code for a better understanding of the sub...
Say you have two classes, A and B. Is it possible to instantiate both classes once and then let class B call methods in class A, and vice versa?
It can be done using double colon (::) ... ... but then the method becomes static - is that a disadvantage? (see example below)
Can it be done in other ways? With interfaces?
This code shows ...
I suppose this could apply to any dynamic language, but the one I'm using is JavaScript. We have a situation where we're writing a couple of controls in JavaScript that need to expose a Send() function which is then called by the page that hosts the JavaScript. We have an array of objects that have this Send function defined so we iterat...
Greetings!
I've spent some time researching how to communicate with SAP from a PHP web application, but the documentation is more than spare. The ways I found are:
Creating IDoc files, some sort of proprietary plain-text format. But how do I stick them in SAP when they are created on the webserver?
Coding a Windows Application using t...
Hi,
I need a class that is based on TPersistent (so it stores the RTTI) and includes default Interfaces handling (QueryInterface, _AddRef, _Release) ... what is the class name I'm looking for?
...
I'm still something of a newbie, and I know my thinking is incorrect; I just don't know where ...
Just about everything in Delphi is descended from TObject. What if everything instead descended from a TInterfaceObject that implemented some trivial interface (e.g., "INamable," with a single method that returned a class's name string)? S...
I have a class that implements an interface, which is made available for plugins.
The declaration of class is quite simple. There is only one instance of this class for an entire application. When the function that returns the interface is called, it calls _AddRef on the retrieved interface before passing it back as result. Unfortunately...
During the parsing of certain xml files, I come across a situation that I have to use interface as labels to identify that certain tags belong to certain category, for example, I created a Tag interface to identify that these classes are used to represent xml tags, and ContainableTag to point out that certain tags can be one of the child...
I saw this code and have some questions:
public class MyClassB : MyClassA, IMyClass
{
void IMyClass.InsertUser(User user) { }
}
Why did they have to prefix the interface, IMyClass and not just do:
void InsertUser(User user) { }
or maybe do
void new InsertUser(User user)
Also, since you are inheriting from MyClassA (which i...
my app asks the user yes-no questions, user replies using a uiswitch on screen. i've been thinking about creating a custom version of the switch that would display yes/no instead of on/off and would use a green/red background as an indicator of the value. after creating a mock up i'm not so sure this is the way to go. using the default s...
I have a list of objects I need to sort according to properties of one of their fields. I've heard that SortedMap and Comparators are the best way to do this.
Do I implement Comparable with the class I'm sorting, or do I create a new class?
How do I instantiate the SortedMap and pass in the Comparator?
How does the sorting work? Will i...