I am pretty new to C# and as a practice exercise was trying to convert a console input of Y's and N's into boolean array of true and false (Y=true N=false).

I get the "Only assignment call, increment, decrement, await and new object expressions can be used as a statement" error. Any suggestions?
Try:
bool[] tempArray = Console.ReadLine().ToList().ConvertAll(ch => Char.Equals(ch, 'Y')).ToArray();
Lambdas do not need the type of their parameters to be specified in the declaration, they are inferred automatically. You would also need to convert to the list of bools to an array with ToArray.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With