When I try to run
InvTotal = g.Sum(d => d.Field<double>("Total")) < 0 ? "W" : "N", I get a
Unable to cast object of type 'System.Double' to type 'System.String' error.
How do I need to change the code for it it compile successfully.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you need correct parenthesis.
Without them the compiler will compile
0 ? "W" : "N"first, and the result of that will be used in the comparison.Sometimes, the C# compiler needs a little help if it comes to the ? operator.