LaunchCodeEducation / csharp-web-dev-curriculum

Hugo version of C# Unit 2
http://education.launchcode.org/csharp-web-dev-curriculum/
1 stars 5 forks source link

Classes for C# ambiguous code example #59

Closed matthewcreek closed 3 months ago

matthewcreek commented 3 months ago

Relevant Link

Code example detailing variable shadowing doesn't have expected output listed, may cause more confusion than clarification.

   public class HelloWorld 
   {

      public string message = "Hello World";

      public void SayHello() 
      {

         string message = "Goodbye World";

         // The line below prints "Goodbye World"
         Console.WriteLine(message);

         // The line below prints "Hello World"
         Console.WriteLine(this.message);
      }
   }

Suggested change would be to add expected output after code block:

using Greetings;

HelloWorld hello = new HelloWorld();

hello.SayHello();

//expected output:
//Goodbye World
//Hello World
matthewcreek commented 3 months ago

notating elsewhere