[324] Type Argument Specification is Redundant

We have the following function in our code base.

public static ReadOnlyCollection ToBo(ReadOnlyCollection items) where T : BusinessObject { Converter converter = new Converter(delegate(T t) { return t as BusinessObject; }); List list = new List(items); return new ReadOnlyCollection(list.ConvertAll(converter).ToArray()); } 324 is showing me that the type argument specification is redundant in the last line - the list.ConvertAll where is marked as redundant. I cannot find a List]]>.ConvertAll() that is not generic. Could someone tell me why the type specifier is redundant, please?

Thanks

Sean

2 comments
Comment actions Permalink

The type argument specifier in invocation is redundant if it could be
inferred from the actual parameter types.
Please refer to C# specs (ECMA-334) part "25.6.4 Inference of type
arguments"
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

"sean kearon" <no_reply@jetbrains.com> wrote in message
news:16612512.1165857442551.JavaMail.itn@is.intellij.net...

We have the following function in our code base.

>

public static ReadOnlyCollection<BusinessObject>
ToBo<T>(ReadOnlyCollection<T> items) where T : BusinessObject
{
Converter<T, BusinessObject> converter =
new Converter<T, BusinessObject>(delegate(T t) { return t as
BusinessObject; });
List<T> list = new List<T>(items);
return new
ReadOnlyCollection<BusinessObject>(list.ConvertAll<BusinessObject>(converter).ToArray());
}

>

324 is showing me that the type argument specification is redundant in the
last line - the list.ConvertAll<BusinessObject> where <BusinessObject> is
marked as redundant.

>

I cannot find a List<T>.ConvertAll() that is not generic. Could someone
tell me why the type specifier is redundant, please?

>

Thanks

>

Sean



0
Comment actions Permalink

Thanks for the quick response, Eugene. I learn quite a lot of new things from using R#.......which is a nice side-benefit :)

Thanks

Sean

0

Please sign in to leave a comment.