I have an interface that describes an specialized list in my application...
Public Interface IAlphabeticListItem
Property StartingLetter() As String
Property DetailsList() As Generic.List(Of DetailsData)
End Interface
Multiple objects implement this interface, but I want to return them in a webservice not as the underlying o...
Why can't I add a delegate to my interface?
...
Why should I implement Interfaces and Dependency Injection on a site with almost no chance for reuse or upgrade by anyone else?
...
Given the following code:
using System.Collections.Generic;
static class Program {
static void Main() {
bar Bar = new bar();
baz Baz = new baz();
System.Console.WriteLine(
"We have {0} bars, rejoice!", bar.Cache.Count);
}
}
public abstract class foo {
public static List<foo> Cache = new List<foo>();
}
public class bar : f...
In Jesse Liberty's Programming C# (p.142) he provides an example where he casts an object to an interface.
interface IStorable
{
...
}
public class Document : IStorable
{
...
}
...
IStorable isDoc = (IStorable) doc;
...
What is the point of this, particularly if the object's class implements the inteface anyway?
...
It's weird that this is the first time I've bumped into this problem, but:
How do you define a constructor in a C# interface?
--Edit--
Some people wanted an example (it's a free time project, so yes, it's a game)
IDrawable
+Update
+Draw
To be able to Update (check for edge of screen etc) and draw itself it will always need a Graphi...
I am looking to 'extending' an interface by providing set accessors to properties in that interface. The interface looks something like this:
interface IUser
{
string UserName
{
get;
}
}
I want something like this:
interface IMutableUser : IUser
{
string UserName
{
get;
set;
}
}
I ne...
After much help from all my StackOverFlow brethren, I managed to create a C++ DLL that calls my C# classes via COM and passes data back and forth to an external application. There was much celebration in the kingdom after that code started working.
Now I have a new problem. I'm expanding the DLL so that it can call different classes (al...
Can you give me an almost overly simplistic understanding of abstract class vs inheritance use and help me so I can truly understand the concept and how to implement? I have a project I'm trying to complete, and am lost on how to implement. I've been chatting with my professor and been told off pretty much, saying that if I can't figure ...
I recently attended an interview and they asked me the question "Why Interfaces are preferred over Abstract classes?"
I tried giving a few answers like:
We can get only one Extends functionality
they are 100% Abstract
Implementation is not hard-coded
They asked me take any of the JDBC api that you use. "Why are they Interfaces?".
C...
I used the "pull interface" refactoring feature of Eclipse today to create an interface based on an existing class. The dialog box offered to create all the new methods of the new interface as "abstract" methods.
What would be the benefit of that?
I thought that the fact that you were allowed to declare interface methods as abstract wa...
I have the following problem with MEF:
Interface definition to be used by host:
Public Interface IExecuteDoSomething
Inherits IAddinSettings
Event DataReceived As EventHandler(Of DataReceivedEventArgs)
Function DoSomething() As Boolean
End Interface
Public Class DataReceivedEventArgs
Inherits EventArgs
Public Sub New...
Many applications (especially the networks' ones e.g. file sharing, sql query program, some multiplayer games) as we know today can be easily provided by using a web interface.
My question is when should I make an application accessible using a browser?
When it will be wise to use a desktop application being built using interfaces like...
Hi there,
I'm new to interfaces and abstract classes. I want to create a couple of interfaces to define core methods and variables for the objects for a shopping cart system. Then I want to create abstract classes which implement the core functions. The idea is that they can be used by other classes in slightly different ways for differ...
I've got an interface that two classes implement at the moment. The data for these classes is read in from an xml file.
e.g.
[Serializable]
public interface IMyInterface { }
[Serializable]
public class MyClass1 : IMyInterface { }
[Serializable]
public class MyClass2 : IMyInterface { }
I want to infer the type from the Xml, is there...
Can a class extend both an interface and another class in PHP?
Basically I want to do this:
interface databaseInterface{
public function query($q);
public function escape($s);
//more methods
}
class database{ //extends both mysqli and implements databaseInterface
//etc.
}
How would one do this, simply doing:
class database impl...
What is the point of writing an interface without members ?
INamingContainer is one example in .NET Framework. And it's described in MSDN as :
Identifies a container control that
creates a new ID namespace within a
Page object's control hierarchy. This
is a marker interface only.
Is it used for just this kind of blocks :
...
I'm aware of these two questions which explain why I can't have a protected/private method in an interface, what I'm trying to work out is how to control from where my methods are called, briefly:
public class EditField : IEditField
{
public EditField() {}
public EditField(IStateMachine stateMachine) {}
public void Action_Co...
Consider this:
public class interface Person : IPerson
{
int ID { get; protected set; }
string FirstName { get; set; }
string LastName { get; set; }
string FullName { get { return FirstName + " " + LastName; } }
}
And this:
public class StubPerson : IPerson
{
int ID { get { return 0; protected set { } }
string FirstNa...
The interfaces in Managed C++ looka bit strange to me since they allow static methods and members inside them. For example, following is a valid MC++ interface.
interface class statinterface
{
static int j;
void Method1();
void Method2();
static void Method3()
{
Console::WriteLine("Inside Method 3");
}
...