Reputation:
I've got a console application that I just made in Visual Studio for Mac and in the Program.cs the code that was created automatically apparently had errors. Here is the code:
using System;
namespace Console
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
And because it put it there not me, you would expect it to work, but it doesn't, it comes up with this error:
Console/Program.cs(13,13): Error CS0234: The type or namespace name 'WriteLine' does not exist in the namespace 'Console' (are you missing an assembly reference?) (CS0234) (Console)
How do fix this?
Thanks!
Upvotes: 10
Views: 5616
Reputation: 652
As your namespace is called Console, when you call WriteLine, it is trying to find a class within your namespace and overriding the default System.Console.
Either rename you namespace OR explicitly specify the namespace for Console which is in the System namespace:
System.Console.WriteLine("Hello World!");
Upvotes: 30