1

I have created a console application in VS2012

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
        }
    }
}

When I try to compile with csc.exe it wont work

D:\temp\ConsoleApplication1> c:\windows\microsoft.net\framework\v4.0.30319\csc.exe /out:d:\temp\test.exe .\Program.cs
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

D:\temp\ConsoleApplication1>

Why is this happening? It will build in VS no problem

Noel
  • 5,037
  • 9
  • 46
  • 69
  • 2
    I see no errors... – Matthew Watson May 31 '16 at 08:42
  • You are missing a `using System;` at the top of the file. – Sean May 31 '16 at 08:43
  • 1
    @Sean If he'd missed that out, the output from csc would include something like `Program.cs(9,13): error CS0103: The name 'Console' does not exist in the current context` - however, it does not. I suspect the OP mistakenly thinks that the warning about csc not being the latest version is an error. – Matthew Watson May 31 '16 at 08:47
  • 2
    I doubt this is a duplicate. I suppose Author just thought it's an error while it is purely informational message and his .exe was compiled fine. – Evk May 31 '16 at 08:50
  • @Noel If you change the writeline to `Console.WriteLine($"Hello");` (i.e. something that requires C#6) then you WILL see an error: `Program.cs(9,31): error CS1056: Unexpected character '$'` – Matthew Watson May 31 '16 at 08:51
  • This is a duplicate as outlined. Don't know how to close it or remove – Noel May 31 '16 at 09:39

0 Answers0