Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perform if / else

receiving error CS1644

I am receiving the following error when trying to compile the code:

error CS1644: Feature `declaration expression' cannot be used because it is not part of the C# 6.0 language specification

Kevin Gates
Kevin Gates
15,053 Points

Please take a snapshot of your workspace and share it here. Here's how to do that: https://teamtreehouse.com/community/workspace-snapshots

Thanks folks. Here is my workspace snapshot: https://w.trhou.se/pn71sawjii

In the console, I attempted to run these commands: mcs Program.cs && mono Program.exe

1 Answer

Steven Parker
Steven Parker
231,269 Points

That's an interesting error message. It indicates that the compiler correctly identified what you were trying to do (a declaration expression), but didn't perform it because it is a version 6 compiler. I believe that feature was originally planned for version 6 but wasn't introduced into the language until version 7.3.

So for now, keep this C#6.0 compiler happy by declaring your variable before the expression it is used in:

        int minutes;
        int.TryParse(entry, out minutes);

You could also change "TryParse" into a plain "Parse" since you are not using the return value:

        int minutes = int.Parse(entry);