Re: Interface VS Delegate
From: Angel J. Hernández (angeljesus14_at_hotmail.com)
Date: 08/25/04
- Next message: Angel J. Hernández: "Re: problems with authenication in C#"
- Previous message: Angel J. Hernández: "Re: Flicker Problem P.S."
- In reply to: Phill: "Interface VS Delegate"
- Next in thread: Christian Heide Damm: "Re: Interface VS Delegate"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Aug 2004 21:55:34 -0400
Hi there... uhm... there are a couple of things you should be aware of...
Interfaces allow us to extend some object's functionality, it's a contract
between the interface and the object that implements it. It is used to
simulate multiple inheritance in C#. In the other hand, we have delegates...
They're just safe callbacks or function pointers. They allow us to notify
that something has happened (Events). As you can see they're different as
well as their use. In your case I'd recommend you to implement an interface
to the objects you want to sort unless... you want to implement some sort of
quicksort algorithm that has a callback (delegate in .NET) as a parameter.
Regards,
-- Angel J. Hernández M. MCSD "Phill" <wackyphill@yahoo.com> escribió en el mensaje news:ac94631d.0408241611.553b6c89@posting.google.com... > When should you use an interface over a delegate? > > Like if you have a class that needs to sort various types of objects. > Should it use a delegate to do the sorting or require that the objects > implement a sorting interface? > > I read that delegates are smaller and of finer granularity than > interfaces. What does that mean exactly? Does it mean they are more > efficient? > > Thanks.
- Next message: Angel J. Hernández: "Re: problems with authenication in C#"
- Previous message: Angel J. Hernández: "Re: Flicker Problem P.S."
- In reply to: Phill: "Interface VS Delegate"
- Next in thread: Christian Heide Damm: "Re: Interface VS Delegate"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|