Click here to Skip to main content
15,887,444 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help required......... Pin
John Kuhn11-Feb-04 20:39
John Kuhn11-Feb-04 20:39 
GeneralDeep copy Hashtable Pin
RickardB11-Feb-04 20:15
RickardB11-Feb-04 20:15 
GeneralRe: Deep copy Hashtable Pin
Heath Stewart12-Feb-04 3:43
protectorHeath Stewart12-Feb-04 3:43 
GeneralRe: Deep copy Hashtable Pin
RickardB12-Feb-04 19:06
RickardB12-Feb-04 19:06 
GeneralRe: Deep copy Hashtable Pin
Heath Stewart13-Feb-04 3:31
protectorHeath Stewart13-Feb-04 3:31 
GeneralListing the tables of MS Access (Error is This) Pin
Daminda11-Feb-04 17:14
Daminda11-Feb-04 17:14 
GeneralRe: Listing the tables of MS Access (Error is This) Pin
krisp11-Feb-04 19:34
krisp11-Feb-04 19:34 
GeneralWhile we're on the subject of language constructs Pin
Tom Clement11-Feb-04 16:27
professionalTom Clement11-Feb-04 16:27 
I ran into a problem that I couldn't see how to solve in C#.

I have a method that takes a Control parameter. I wanted to further restrict it so that is only took Control objects that also implemented a particular interface. So I'd like to be able to declare something like:
public interface IMyNotificationsControl : Control
{
   void MyNotification1();
   void MyNotification2();
}


Of course, this fails at compilation, since Control is an object, not an interface.

If it were permitted, it would mean that an object of this type would support the entire Control interface (in fact derived from it) but also implement the additional methods.

That way, I could declare my function like this:
public void MyFunction(IMyNotificationsControl control)
{
  ...
}



Of course, you could derive a new object type from Control to accomplish this, but in my case, I need to take a wide variety of Control types (e.g. different classes derived from specific controls like TreeView etc.

I realise that multiple inheritance would solve this problem. But is there a better way to deal with it in C# other than casting and trusting the programmer?

Tom Clement
GeneralRe: While we're on the subject of language constructs Pin
krisp11-Feb-04 16:47
krisp11-Feb-04 16:47 
GeneralRe: While we're on the subject of language constructs Pin
Kentamanos11-Feb-04 16:54
Kentamanos11-Feb-04 16:54 
GeneralRe: While we're on the subject of language constructs Pin
Tom Clement11-Feb-04 17:07
professionalTom Clement11-Feb-04 17:07 
GeneralRe: While we're on the subject of language constructs Pin
Werdna13-Feb-04 12:23
Werdna13-Feb-04 12:23 
GeneralStoring RichText data in Access Database Field Pin
bjulien11-Feb-04 15:51
bjulien11-Feb-04 15:51 
GeneralRe: Storing RichText data in Access Database Field Pin
John Kuhn11-Feb-04 16:29
John Kuhn11-Feb-04 16:29 
GeneralRe: Storing RichText data in Access Database Field Pin
Heath Stewart12-Feb-04 3:35
protectorHeath Stewart12-Feb-04 3:35 
GeneralRe: Storing RichText data in Access Database Field Pin
bjulien12-Feb-04 8:03
bjulien12-Feb-04 8:03 
GeneralRe: Storing RichText data in Access Database Field Pin
Heath Stewart12-Feb-04 8:36
protectorHeath Stewart12-Feb-04 8:36 
GeneralRe: Storing RichText data in Access Database Field Pin
bjulien12-Feb-04 10:25
bjulien12-Feb-04 10:25 
GeneralExplicit abstract methods. Pin
krisp11-Feb-04 15:29
krisp11-Feb-04 15:29 
GeneralRe: Explicit abstract methods. Pin
Kentamanos11-Feb-04 15:52
Kentamanos11-Feb-04 15:52 
GeneralRe: Explicit abstract methods. Pin
krisp11-Feb-04 16:21
krisp11-Feb-04 16:21 
GeneralRe: Explicit abstract methods. Pin
Kentamanos11-Feb-04 16:45
Kentamanos11-Feb-04 16:45 
GeneralRe: Explicit abstract methods. Pin
krisp11-Feb-04 17:06
krisp11-Feb-04 17:06 
GeneralRe: Explicit abstract methods. Pin
Kentamanos11-Feb-04 17:41
Kentamanos11-Feb-04 17:41 
GeneralFile Backup Pin
Demo36011-Feb-04 14:50
Demo36011-Feb-04 14:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.