Alex A
asked on
.Net Console app: System.Console.WriteLine
Hi, there is 'using System;' in the beginning of the file.
However Console. WriteLine doesn't compile and requires System.Console.WriteLine.
Why? How can it be fixed?
Thanks.
However Console. WriteLine doesn't compile and requires System.Console.WriteLine.
Why? How can it be fixed?
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is your using statement outside of the class?
Are you sure you haven't defined your own "System" namespace in your project?
ASKER
using System;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
namespace AdventureWorksWeb.Console
{
class Program
{
private static readonly HttpClient client = new HttpClient();
static void Main(string[] args)
{
System.Console.WriteLine(" Testing 2 API methods, please choose");
System.Console.WriteLine(" 1. Get products");
System.Console.WriteLine(" 2. Get product by id");
string choice = System.Console.ReadLine();
if (choice == "1")
{
ProcessProducts().Wait();
}
else
{
System.Console.WriteLine(" Enter Product ID");
string Id = System.Console.ReadLine();
ProcessProduct(Id).Wait();
}
}
}
}
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
namespace AdventureWorksWeb.Console
{
class Program
{
private static readonly HttpClient client = new HttpClient();
static void Main(string[] args)
{
System.Console.WriteLine("
System.Console.WriteLine("
System.Console.WriteLine("
string choice = System.Console.ReadLine();
if (choice == "1")
{
ProcessProducts().Wait();
}
else
{
System.Console.WriteLine("
string Id = System.Console.ReadLine();
ProcessProduct(Id).Wait();
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or just remove the .
ASKER
Yes, thank you!
System.Console.WriteLine should still have worked, Console.WriteLine won't
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.