Re: forEach and Casting



Jason Cavett wrote:

Now, unfortunately, despite some of the reading I've done, I don't
fully understand the notation. Would you mind explaining it as I
don't like to use a tool I don't understand for fear of misuse.

Well, that's not very hard to understand. There is a single type parameter (declared with type variable E) which serves two roles, 1) constraints returned list elements type to any valid subclass of your base class, and 2) declares a type (using wildcard to allow subclasses) of Class objects being accepted by the method.

Whatever the actual type parameters are, they must match must that declaration, that's all.


HTH,
piotr
.



Relevant Pages

  • Re: Confused on CodeBehind Partial Classes in 2.0
    ... public partial class _Default: System.Web.UI.Page ... IRequiresSessionState is an interface telling that the Page uses session ... Basically they still have the same base class which is ... It is already assumed since *1.cs already declares the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Confused on CodeBehind Partial Classes in 2.0
    ... public partial class _Default: System.Web.UI.Page ... IRequiresSessionState is an interface telling that the Page uses session ... Basically they still have the same base class which is ... It is already assumed since *1.cs already declares the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: BindingFlags.Internal, where is that?
    ... internal member is declared in a base class. ... And having a base class that declares a property as internal causes the call ... class type makes it return the property. ...
    (microsoft.public.dotnet.languages.csharp)