Taking a lesson from scripting languages corresponding to Python and JavaScript, Microsoft has launched a file-based apps functionality for the C# language, which is meant to streamline C# improvement.
Launched in .NET 10 Preview 4, the brand new function permits builders to run a stand-alone C# (.cs) file instantly with the command, dotnet run app.cs
. Builders now not have to create a venture file or scaffold a complete software to check a take a look at snippet, run a fast script, or experiment with an concept, wrote Damian Edwards, principal architect at Microsoft, in a Could 28 weblog publish asserting the function. Beforehand, working C# code utilizing the dotnet CLI has required a venture construction that included a .csproj file. Builders can get began with the function by downloading .NET 10 Preview 4.
File-based apps decrease the entry barrier to attempting out C# and make the language a more-attractive selection for studying, prototyping, and automation eventualities, Edwards mentioned. Builders get a fast begin whereas no venture file is required, there may be “first-class” CLI integration, and the aptitude scales to actual functions. There is no such thing as a separate dialect or runtime; when a script grows up, it could evolve right into a full-fledged venture utilizing the identical language, syntax, and instruments. With .NET 10 Preview 4, file-based apps additionally help a set of file-level directives to declare packages, SDKs, and properties (that are saved in venture information for venture apps) with out leaving a .cs file.