I am loading a file that contains a CSV and I’m using LINQ to determine if there any failures and I have fallen at the first hurdle:
var lines = File.ReadAllLines(@"C:\Projects\Misc Files\FontToImageGenerator\test\testMODIFIED.txt");
foreach (string line in lines)
{
var splitup = line.Split(',');
//Check first 3 are from A-q or 65-113 in ASCII
var first3ok = splitup.Take(3).All(x => Char.GetNumericValue((char)x[0]) >= 65 && <= 113); //****This doesn't compile**** IEnumberable<string> does not contain a defintition for All and the best overload arguments contains invalid arguemnts
//Check next 20 chars and they alternate matching A-q and 1-9
//Check the next char is from A-I
//Last 8 chars in the line should contain 2 chars uppercase from A-Z
}
The current error really doesn’t have anything to do with LINQ. You’ll see the same thing if you do:
That’s just not valid C# – you haven’t got a valid operand for the
<=part. You’d need something like:I don’t think that’s really what you mean though – I think you’ve misunderstood what
GetNumericValuedoes. I suspect you really want:So:
Note that this isn’t checking the first three characters – it’s checking the first character of each of the first three bits of the comma-separated string. It’s unclear whether that’s what you meant or not.
However, it looks to me like this is one situation where you’d be better off using a regex…