I am new to C#, but from my understanding this code should work. Why doesn't it work?
This is an example of my code.
List<Car> cars // This has many cars initialized in it already
if (() => {
foreach(Car car in cars){
if (car.door == null) return true;
}
}){then .......}
Simply put, all I want the code to do is run the if statement if any car does not have a door.
After trying to compile I get this error:
Cannot convert lambda expression to type 'bool' because it is not a delegate type.
() => {..., not()={... Of course, it wouldn't work if you were using it, but that's another story.