ファイルベース実行例1.
File-based Apps で、別ファイルに記述したクラスメソッドを利用する
Section titled “ファイルベース実行例1. File-based Apps で、別ファイルに記述したクラスメソッドを利用する”File-based Apps で、たとえば別ファイルに記述した静的クラス内の静的メソッドを利用するには、#:include ディレクティブを使用します。
ソースコード
Section titled “ ソースコード”Hoge.cs ( 実行する、C# ファイル )
Section titled “ Hoge.cs ( 実行する、C# ファイル )”#!/usr/bin/env dotnet#:include Piyo.csConsole.WriteLine(Piyo.Msg("Hoge"));Piyo.cs ( include する、別 C# ファイル )
Section titled “ Piyo.cs ( include する、別 C# ファイル )”public static class Piyo{ public static string Msg(string str) => $"{str}, Piyo!";}$> dotnet Hoge.csHoge, Piyo!