Re: C# - Adding event delegate declarations to interfaces



steve <steve@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I want to be able to hirearchally define event delegate (declarations)
WITHIN interfaces.

Unfortunatelly C# 1 doesn't appear to support it.

What exactly does this mean? What is hierarchical?

Do you mean that the declaration of the delegate type is lexically
nested inside the interface? You can't do that, but it wouldn't give you
anything anyway - it would just mean that every client of the delegate
type would have to fully qualify the delegate type, which would be a
pain for all the users.

How does the following look as a work-around? Are there better ways of
doing this?

I'm not sure why you seem to want to lexically enclose types inside your
interface type - if that's the functionality you're after. Nested types
aren't a common pattern in C#. They are common in C++ for enumeration
types, for example, but that's because C++ enumeration types don't need
to be qualified by the enumeration name.

C# doesn't have this feature/flaw, so nested types are generally only
required when the inner type needs access to private and protected
fields of the enclosing type. Since interfaces can only have public
members, there isn't a need for types nested inside interfaces.

-- Barry

--
http://barrkel.blogspot.com/
.



Relevant Pages

  • Re: MprAdminInterfaceEnum
    ... > Trying to enumerate interfaces on RRAS. ... the enumeration cannot be continued. ... > public static extern int MprAdminInterfaceEnum( ...
    (microsoft.public.dotnet.framework.interop)
  • Re: My idea for filtering an Enumeration or Iterator
    ... > interfaces in java.util. ... trivial to sub-class it to implement an enumeration for that class. ... If you absolutely need a generic class that includes more than one ...
    (comp.lang.java.programmer)
  • Re: Question about Iteration and forEach
    ... I just defined a couple if interfaces; ... public static void DoTest() ... private MyListlist; ... If you want the ability to adjust your position within the enumeration, you can usually just use a normal "for" loop with an index to access individual items within the collection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CodeDom foreach
    ... IEnumerate is supported? ... If either of the generic interfaces are implemented, ... returned during enumeration using Type.GetGenericArgumentson the ... "Mubashir Khan" wrote: ...
    (microsoft.public.dotnet.framework)