I'm using .net core to create and run some very simple C# code through the command line. I create a new console app using dotnet new console
. It creates a .csproj file in the name of the directory I'm in (classes). So I have a classes folder which contains a classes.csproj file, a Program.cs file and some other folders.
In order to create some classes I need some other .cs files here, but I can't find out how to do it. I've tried the File:New
command according to https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/introduction-to-classes, but I must be using the wrong syntax since it says:
The filename, directory name, or volume label syntax is incorrect.
Since I'm pretty much new to command line and coding(obviously), I've googled for some cmd syntax but still couldn't find anything to get it work.
I know It can be easily done in Visual Studio but I was wondering if there is a way to do it using cmd.
Unfortunately, there is no command line to create a C# file in dotnet cli
but if you want to create a C# file with the terminal you can use bellow command
in Linux bash OR git bash in windows
touch YourFileName.cs
in Windows cmd
type NUL > YourFileName.cs