Reporter | 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