C
C#2y ago
Galelao

❔ 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 }]
12 Replies
Auros
Auros2y ago
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?
phaseshift
phaseshift2y ago
$code
MODiX
MODiX2y ago
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/
Galelao
GalelaoOP2y ago
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
Auros
Auros2y ago
OH! My bad, I didn't see the error
phaseshift
phaseshift2y ago
It means that the message then please format code properly
Auros
Auros2y ago
On line 22, you're using \ which escapes something in a string without escaping anything I can only presume that \ should be \n
Galelao
GalelaoOP2y ago
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 }]
Auros
Auros2y ago
That's not an error, it's just a warning which explains that the setter for Console.WindowHeight only works on Windows
Galelao
GalelaoOP2y ago
Ah, ok thanks for your help!! 🙂
Auros
Auros2y ago
If you go into your .csproj file, you can change
<TargetFramework>netX.0</TargetFramework>
<TargetFramework>netX.0</TargetFramework>
to
<TargetFramework>netX.0-windows</TargetFramework>
<TargetFramework>netX.0-windows</TargetFramework>
to suppress the warning
Accord
Accord2y ago
Was 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.
Want results from more Discord servers?
Add your server