❔ Learning C# Need help fixing a problem.
I am following a tutorial but am stuck because of a problem that is coming up I do not understand it.
Here is my Code:
using System;
namespace Learning_Unity
{
class Program
{
static void Main(string[] args)
{
Console.Title = "SnowCrash";
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WindowHeight = 40;
Console.WriteLine("Hello, what's your name?"); Console.ReadLine(); Console.WriteLine("Ah yes, I see. \nThank you for that valuable information."); Console.WriteLine("What is your address?"); Console.ReadLine(); Console.WriteLine("Haha, this is fun! \I can't believe I am talking to a real person.");
Console.ReadKey(); } } } Here is the error [{ "resource": "/c:/Users/-------/Desktop/Game Dev/Learning Unity/Program.cs", "owner": "msCompile", "code": "CS1002", "severity": 8, "message": "; expected [C:\Users\------\Desktop\Game Dev\Learning Unity\Learning Unity.csproj]", "startLineNumber": 22, "startColumn": 75, "endLineNumber": 22, "endColumn": 75 }]
Console.WriteLine("Hello, what's your name?"); Console.ReadLine(); Console.WriteLine("Ah yes, I see. \nThank you for that valuable information."); Console.WriteLine("What is your address?"); Console.ReadLine(); Console.WriteLine("Haha, this is fun! \I can't believe I am talking to a real person.");
Console.ReadKey(); } } } Here is the error [{ "resource": "/c:/Users/-------/Desktop/Game Dev/Learning Unity/Program.cs", "owner": "msCompile", "code": "CS1002", "severity": 8, "message": "; expected [C:\Users\------\Desktop\Game Dev\Learning Unity\Learning Unity.csproj]", "startLineNumber": 22, "startColumn": 75, "endLineNumber": 22, "endColumn": 75 }]
12 Replies
Is there anything in particular you do not understand about this? Or do you not understand it in general? Does the tutorial not cover the explanation of it?
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/I don't understand why the error is happening. I followed all the steps and my code looks like the tutorials does
Sorry I don't understand what that means
OH! My bad, I didn't see the error
It means that the message then please format code properly
On line 22, you're using
\
which escapes something in a string without escaping anything
I can only presume that \
should be \n
Ah, ok now I have a new problem that came up?
[{
"resource": "/c:/Users/------/Desktop/Game Dev/Learning Unity/Program.cs",
"owner": "msCompile",
"code": "CA1416",
"severity": 4,
"message": "This call site is reachable on all platforms. 'Console.WindowHeight.set' is only supported on: 'windows'. [C:\Users\------\Desktop\Game Dev\Learning Unity\Learning Unity.csproj]",
"startLineNumber": 11,
"startColumn": 13,
"endLineNumber": 11,
"endColumn": 13
}]
That's not an error, it's just a warning which explains that the setter for
Console.WindowHeight
only works on WindowsAh, ok thanks for your help!! 🙂
If you go into your
.csproj
file, you can change
to
to suppress the warningWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.