C# C# Basics C# Syntax Variables

Ra Bha
Ra Bha
1,241 Points

Hello, is it recommended that we type out what's happening on the lesson into the Workspace during the lessons? Thanks!

The lesson mentions launching a workspace but then doesn't explicitly say that we should type what's being referred to by the instructor onto the Workspace. I'm just checking whether that's the expectation for highest quality of learning and instruction. Thank you!

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Ra Bha! I would highly recommend doing that. In my experience, students who do not type along tend to encounter more syntax errors later. The more you type along, the more second-nature some things will become, like adding a semicolon at the end of a statement. It may not seem like a big thing now, but later when your code won't compile because of a missing semicolon, you might wish you'd gotten in the habit early :smiley:

Hope this helps! :sparkles:

Jesse Kill
Jesse Kill
42 Points

Hello there,

I tried following along in the video. When I typed this out:

class Program
{
    static void Main(string[] args)
    {
        var number = 4;
        var gretting = "hello";
        system.console.writeline(number);
        system.console.writeline(greeting);

    }
}

But got three errors:

Program.cs(8,34): error CS0103: The name 'greeting' does not exist in the current context [/home/treehouse/work space/workspace.csproj]
Program.cs(6,13): warning CS0219: The variable 'gretting' is assigned but its value is never used [/home/treeho use/workspace/workspace.csproj]

What have I done wrong?

Cheers, Jesse

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Jesse Kill! First, capitalization matters. If you're programming, you should assume that literally everything is case-sensitive. This even includes file and folder names.

You have:

system.console.writeline();

But that should be:

System.Console.WriteLine();

Secondly, you have a spelling error. At first, you created a variable named gretting, but you meant for it to be greeting. Check the number of "t"s and "e"s.

Hope this helps! :sparkles:

Ra Bha
Ra Bha
1,241 Points

Hello Jesse, one thing I kept doing wrong was forgetting to save the file each time I updated the code. This may or may not be an issue for you but do remember to save the file each time you run the code in Console in the Workspace. Otherwise, the Console will run the previous code that was saved, not what is in your file presently.

Hope this helps.