Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-299540: Show a warning about possible InvalidCastException when result of LINQ methods in System.Linq.Enumerable is cast to an array or List

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created May 3, 2012 11:18:46 PM
Updated May 3, 2012 11:18:46 PM
Priority Normal
Type Feature
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
using System.Collections.Generic;
using System.Linq;

class C
{
    static void Foo(IEnumerable<string> strings)
    {
        var arr = (string[]) from s in strings select s.ToLower();
        var list = (List<string>) from s in strings select s.ToLower();
    }
}


Suggest to invoke .ToArray() or .ToList() instead.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>