For learning purposes, I use csc.exe myprogram.cs
shipped with Visual Studio Community (my version 17.3.4) to compile basic C# programs. It mostly works, except when using what appears to be latest language features, for example, array range shorthand array[0..]
or element from end shothand array[^1]
.
For example, when trying to access [^1]
element.
Arrays.cs(58,47): error CS0518: Predefined type 'System.Index' is not defined or imported
Arrays.cs(58,47): error CS0656: Missing compiler required member 'System.Index..ctor'
I tried passing -langversion:preview
to csc but still not working. Also I was unable to find proper usings
for it to work.
Can I somehow get those features to work with basic csc compilation? They worked when I created csproj
file and used dotnet build
, but doing so was multiple times slower than using just csc. Thanks!