My coding is correct but I cannot submit it because of one error that I don't know how to solve

Hi, so I’ve been doing exercise in C# Luciano’s lasagne and my code’s correct but I keep getting this error

You can’t arbitarily execute lines like you’re doing on the first few lines. It won’t work in our editor.

1 Like

To be more specific: the C# track expects you to create a class library, not an application. And top-level statements are only allowed in the latter.

I’ve had the same issue; I almost gave up.
Luckily, I stumbled on this topic.

I had to remove the following code:

var lasagna = new Lasagna();
lasagna.ExpectedMinutesInOven();        // 40
lasagna.RemainingMinutesInOven(30);     // 10
lasagna.PreparationTimeInMinutes(2);    // 4
lasagna.ElapsedTimeInMinutes(3, 20);    // 26

And it worked fine.
I think it should be more self-explanatory.

It probably comes down to reading the error message that is given. Learning to read and understand what the language is telling you is a skill that is going to be really handy to be able to read and understand.

But I am glad you posted the question.

Do be aware that not everyone can read the text in pictures easily, so if it is text you want to communicate, copy and paste is likely easier for everyone involved.

1 Like