The concept of having the interafce as part of a class definition is stating that this interface onlt has meaning in terms of this class. As you had a rquirement that classes outside the assembly could only see the interface if they derived from a particular class (Class2?) then it seemed to fit your model.
Regards
Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<br************ *@fe37.usenetse rver.com>
"Richard Blewett [DevelopMentor]" <ri******@devel op.com> wrote in message
news:Oy******** *****@tk2msftng p13.phx.gbl...
Assembly 1:
public class Class2
{
protected internal interface IFoo
{
}
}
Assembly 2 referencing assembly 1:
class Bar : Class2
{
protected void Quux(Class2.IFo o f)
{
}
}
Is this what you mean? This is supported (the above compiles fine). Or do
you mean something else?
Might be -- I'd have to try it out. I didn't know that interfaces
could be defined from *within* a class. I've been defining then
outside the class and implementing them within the classes.
I'll see if it gets me where I want to go.
BTW -- what does it mean to define an interface from
within a class. How is this different (other than possibly
allowing my scope issue to be solved) how is it different
than defining an interface outside the class.
It seems somhow, well ... wrong. The interface might be
implemented by several different classes. Why should it
be defined within one class and not another -- hence my
habit to declare them outside of classes.
Am I crazy?
You've got an example: protected void Quux(Class2.IFo o f)
which makes an (invalid) association in my mind between
Class2 and IFoo -- IFoo might also be implemented by
Class3, Class4 and Class5 -- why should it be tied to
Class2? I'd much rather have:
protected void Quux(IFoo f) without any knowledge of
Class2 -- ain't that the whole point of an interface? That
it *hides* the actual concrete object behind an interface
such that you don't care if it's a Class2 or Class3 or Class4,
just that it implements IFoo?
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
[microsoft.publi c.dotnet.langua ges.csharp]