Re: CodeDom foreach




"Kevin Burton" <KevinBurton@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F3B3C9DE-D7DA-4819-9365-760375492ECD@xxxxxxxxxxxxxxxx
Sorry, one more question. Given a Type how do I tell if IEnumerable or
IEnumerate is supported? Then from the Type how do I get the Type that
IEnumerate would return? In other words what is the Type of the Current
method?

Type.GetInterfaces()

then check each against System.Collections.IEnumerable,
System.Collections.IEnumerator, System.Collections.Generic.IEnumerable<T>,
and System.Collections.Generic.IEnumerator<T>.

If either of the generic interfaces are implemented, you can get the type
returned during enumeration using Type.GetGenericArguments() on the
interface in question. If only one of the System.Collections interfaces is
listed, the enumerator gives objects.


Thank you.

"Mubashir Khan" wrote:


.



Relevant Pages

  • RE: Contains Method of Collection
    ... Welcome to MSDN newsgroup. ... ICollection, IEnumerate, IList ... And the IEnumeate and ICollection only provide enumerate interface to loop ...
    (microsoft.public.dotnet.languages.vb)
  • 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: C# - Adding event delegate declarations to interfaces
    ... Do you mean that the declaration of the delegate type is lexically ... They are common in C++ for enumeration ... so nested types are generally only ... Since interfaces can only have public ...
    (microsoft.public.dotnet.languages.csharp)