Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
14,855 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
216,826 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);