interface

How can an auto-implemented property having different access levels be described by an interface?

This class property is what I'm trying to refactor into an interface. public class Stuff : IStuff { public int Number { get; protected internal set; } } Visual Studio 2008 refactoring tools extract the following interface // Visual Studio 2008's attempt is: public interface IStuff { int Number { get; } } ...

How do I override the equals operator == for an Interface in C#?

I have defined the following interface public interface IHaveAProblem { string Issue { get; set; } } And here is the implementation of the IHaveAProblem public class SomeProblem : IHaveAProblem { public string Issue { get; set; } public override bool Equals(object obj) { SomeProblem otherObj = obj as SomePro...

Typing polymorphic values with multiple interfaces in C#

Is there any type-safe, compile-time checked possibilty of referring to values that implement multiple interfaces? Given interface A { void DoA(); } interface B { void DoB(); } I'm able to write code for objects implementing A or B, but not both. So I've to come up with ugly wrappers: class ABCollection { private class ...

Button to sound in Interface Builder?

I'm working with the iPhone 3.0 SDK (bit of a novice really), and I have set up an Interface Builder View with several UIButtons in it. I also have several sound files in the Xcode project. I have searched for this and none of the solutions seem to work for me. Does anyone know how to make a short sound play once upon pressing a button?...

What is an alternative to having static abstract methods?

I'm having some problems trying to figure out how to solve a problem without being able to have static method in an abstract class or interface. Consider the following code. I have many Wizards that inherit from AbsWizard. Each wizard has a method GetMagic(string spell) that only returns magic for certain magic words, yet all instances o...

How can I get the cellular connection interface name on the iPhone?

I did not find any clues on how to get the cellular connection interface name. BTW is the cellular connection interface static or it can change for example from en1 to en2? Thanks ...

Setting the value to an int when clicking a button in Cocoa

Ok, i'm new to the whole GUI programming so this might be a very simple question but has proven difficult to me. I have an application with 3 buttons. Button A is the main button, it starts and stops the application. I created a class with an IBAction on it and wrote the code for that button. it works. I also have button B and C that ar...

Mapping Interfaces to Methods in Global.asax

I was recently at a Techdays seminar, at the SOLIDify Your Microsoft ASP.MVC MVC Applications session. The instructor had a demo that had mapping Interfaces to Methods from the Global.asax file OnApplication_Start(). So anywhere in the web application he could simply do IDate.GetMyDate() and it would return the date. I was wondering...

Passing a pointer to a base class to derived class's member functions in C++

How to access the derived class's data from one of its instances' member function that receives a pointer to the base class? I have: class Base{ public: virtual void compare(Base*)=0; }; class A: public Base{ int x; public: A(); void compare(Base*); }; cla...

If I have an attribute declared over a method in an interface, do I need to put the attribute again in the method delcaration in the class?

Let's say I have a method such as [OperationContract(IsOneWay = true)] void UpdateIndex(IndexElement[] indexElements); in an interface. When I implement void UpdateIndex(IndexElement[] indexElements); in a class file, do I have to repaste the method attribute or will the compiler know from the definition in the inter...

How can I force inheriting classes to implement a static method in C#?

All I want to do is make sure that child classes of the class Item implement a static method and I want this to be checked at compile time to avoid runtime errors. abstract classes with static methods don't seem to work: ERROR: A static member cannot be marked as override, virtual, or abstract public abstract class Item { ...

C#: Subclass List<Something>?

I have a class EqualCondition which implements my own interface ICondition, which has only one method: SatisfiedBy(Something). public class EqualCondition : ICondition { private Something m_Something; public HelloCondition(Something something) { m_Something = something; } // Magic!!! public bool SatisfiedBy...

C# multiple settings files with same interface

I'm trying to create a program with two (or more) discrete sets of settings, that both conform to the same interface. Particularly I'd like to do something like the following, using designer generated settings: IMySettings settings = Properties.A; Console.WriteLine(settings.Greeting); settings = Properties.B; Console.WriteLine(settings...

Determine what interfaces a type implements

Hey guys Just a quick one... How do I determine what interfaces a type implements? Cheers Anthony ...

Java abstract static Workaround

I understand that neither a abstract class nor an interface can contain a method that is both abstract and static because of ambiguity problems, but is there a workaround? I want to have either an abstract class or an interface that mandates the inclusion of a static method in all of the classes that extend/implement this class/interfac...

Threading: does c# have an equivalent of the Java Runnable interface?

Does c# have an equivalent of the Java Runnable interface? If not how could this be implemented or is it simply not needed? thanks. ...

should every single parameter use an interface?

If i have a method like: public void AddProduct(Product product) { } Should I have all my classes implement an interface so I can do: public void AddProduct(IProduct product) { } (where product is an entity (maps to a db table) ...

C# interfaces and type masquerading

My subclasses don't appear to be able to masquerade as the base class when satisfying interface requirements. For example: class MyBaseClass {} class MySubClass : MyBaseClass {} interface MyInterface { MyBaseClass someFunction(); } class MyImplementation : MyInterface { public MySubClass someFunction() { return null; } } Ge...

Remove centering of NSPanel window on screen

If the code already has [window center], is there anyway to change the position of NSPanel without changing the code? I don't have access to the code and I'm trying to change the position of a NSPanel window toward the bottom of the screen and off-center to the left and I've tried Interface Builder Size Inspector option but I'm not able ...

Any real example of using interface related to multiple inheritance

I m trying to understand Interfaces so that I can implement them in my programs but I m not able to imagine how should i use them. Also give me some eg of using them with multiple inheritance in C# ...