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

RSRP-329289: Invalid Cast in Convert to Linq Sum

$
0
0
Reporter Brian (O.E) Brian (O.E)
Created Aug 17, 2012 8:31:11 PM
Updated Apr 17, 2018 7:02:08 PM
Subsystem Code Analysis - Linq Tools
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Bug
Fix version Backlog
Affected versions 2018.1, 6.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
Code
foreach (int c in "12345")
{
demo +=c;
}

Expected:
Code
int demo = "12345".Sum(c => (int)c);

Result:
Code
int demo = "12345".Cast<int>().Sum();
//Runtime Error: Specified cast is not valid

Int is a representation-changing conversion

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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