Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

osawa-koki/sample-CommandLineParams-parser.cs

Repository files navigation

sample-CommandLineParams-parser.cs

C#でコマンドライン引数を解析するサンプルプロジェクト。
代わりにMicrosoft.Extensions.Configuration.CommandLineを使用する。

説明

特になし。
非常に簡単に使える。

using Microsoft.Extensions.Configuration;

var builder = new ConfigurationBuilder();
builder.AddCommandLine(args);

var config = builder.Build();

Console.WriteLine($"Key1: '{config["Key1"]}'");
Console.WriteLine($"Key2: '{config["Key2"]}'");
Console.WriteLine($"Key3: '{config["Key3"]}'");
Console.WriteLine($"Key4: '{config["Key4"]}'");
Console.WriteLine($"Key5: '{config["Key5"]}'");

補足

Microsoft.Extensions.CommandLineUtilsは既に非推奨。

参考文献

About

C#でコマンドライン引数を解析するサンプルプロジェクト。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published