Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/preprocessor-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ The C# compiler ignores any preprocessor directive that starts with `#:` or `#!`
The `#!` preprocessor directive enables unix shells to directly execute a C# file using `dotnet run`. For example:

```csharp
#!/usr/local/share/dotnet/dotnet run
#!/usr/bin/env dotnet run
Console.WriteLine("Hello");
```

The preceding code snippet informs a Unix shell to execute the file using `/usr/local/share/dotnet/dotnet run`. (Your installation directory for the `dotnet` CLI can be different on different Unix or macOS distributions). The `#!` line must be the first line in the file, and the following tokens are the program to run. You need to enable the *execute* (`x`) permission on the C# file for that feature.
The preceding code snippet informs a Unix shell to execute the file using `dotnet run`. The `/usr/bin/env` command locates the `dotnet` executable in your PATH, making this approach portable across different Unix and macOS distributions. The `#!` line must be the first line in the file, and the following tokens are the program to run. You need to enable the *execute* (`x`) permission on the C# file for that feature.

The `#:` directives that are used in file-based apps include:

Expand Down
Loading