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#

Write code to print “C# Rocks!” to the console if language equals “C#”.

i'm stuck help

8 Answers

I found that my error was coming from copy and pasting “C# Rocks!” The "" are stylized and the script program hates them!

Very, very tricky! Thanks for the tip. This was tripping me up, too!

Larry R
Larry R
13,955 Points
string language = Console.ReadLine();

if(language == "C#")
{
  System.Console.WriteLine("C# Rocks!");
}

Sagar mybe i'm making mistake send your explanation in code form mybe it helps

Sagar Bharadia
Sagar Bharadia
10,722 Points

Are you able to link me to the challenge which you are currently stuck on? If you are still stuck on it?

Michael Apps
Michael Apps
4,907 Points

Hello. Am I missing something here? The code that it inputs for you string language = Console.ReadLine(); does not have the namespace System in front of it. Because of that I figured the line it was asking me to write didn't require it either Console.WriteLine("C# Rocks!"); It was failing me because I didn't use 'System.Console.WriteLine.....', but then shouldn't it have failed on the ReadLine it put in for me as well?

i had solved it thanks for your assistance

Sagar Bharadia
Sagar Bharadia
10,722 Points

To print in c# I believe it is System.Console.WriteLine(""); Hope this helps! You can also use System.Console.Write(""); You put the text within the "".

its not working Sugar

Sagar Bharadia
Sagar Bharadia
10,722 Points

Herbert, if in the case you have declared that you are using system at the top of your code (Using System;) then all you would need to write it Console.WriteLine(""); Hope this helps!