DoboWiki
Top
> .NETプログラミング研究/108 をテンプレートにして作成
.NETプログラミング研究/108 をテンプレートにして作成
開始行:
#title(Command Line Parser Libraryを使ってコマンドライン...
#navi(.NETプログラミング研究)
#contents
*Command Line Parser Libraryを使ってコマンドライン引数を...
アプリケーションを起動する時に指定されたコマンドライン引...
コマンドライン引数を解析するためのフリーのクラスやライブ...
**Command Line Parser Libraryをインストールする [#t1338ee6]
***NuGetを使った方法 [#bcbcb8fa]
Command Line Parser Libraryは[[NuGet>http://nuget.codeple...
&embed(<a href="https://www.flickr.com/photos/dobondotnet...
もしVisual Studio 2010未満でNuGetがインストールできないの...
Visual Studio 2010以上でNuGetがインストールされているなら...
+Command Line Parser Libraryを使用するプロジェクトをVisua...
+メニューの[ツール]-[プロジェクト]-[NuGetパッケージの管理...
+ダイアログの左側で「オンライン」を選択し、右上の「オンラ...
+見つかった「Command Line Parser Library」を選択して、「...
このようなダイアログを使わずに、パッケージマネージャーコ...
PM> Install-Package CommandLineParser
***バイナリをダウンロードする方法 [#r7c3a110]
NuGetを使わずに、バイナリを直接ダウンロードしてインストー...
**Command Line Parser Libraryが解析できるコマンドライン引...
Command Line Parser Libraryが解析できるコマンドライン引数...
例えば、
-o test.txt -v
というコマンドライン引数を解析することはできますが、
/o test.txt /v
というものは解析できません。
**簡単な使い方 [#z240b773]
それでは早速使ってみましょう。
ここでは、"o"と"v"2つのオプションを定義することで、例えば
-o test.txt -v
というコマンドライン引数を、
「"o"オプションには"test.txt"が指定されていて、"v"オプシ...
と解析できるようにします。
まずコンソールアプリケーションのプロジェクトを作成して、...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'String型のオプション
<CommandLine.Option("o"c)> _
Public Property OutputFile As String
'Boolean型のオプション
<CommandLine.Option("v"c)> _
Public Property Overwrite As Boolean
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//String型のオプション
[CommandLine.Option('o')]
public string OutputFile
{
get;
set;
}
//Boolean型のオプション
[CommandLine.Option('v')]
public bool Overwrite
{
get;
set;
}
}
}}
このクラスにはOption属性が適用されたプロパティが2つありま...
#column(補足){{
プロパティには、GetとSetの両方が必要です。Getだけではエラ...
}}
次に、解析結果を取得するためのコードを記述します。これは...
#code(vbnet){{
Module Module1
'エントリポイント
Sub Main(args As String())
'Optionsクラスのインスタンスを作成
Dim opts = New Options()
'コマンドライン引数を解析する
Dim isSuccess As Boolean = _
CommandLine.Parser.Default.ParseArguments(arg...
If isSuccess Then
'解析に成功した時は、解析結果を表示
Console.WriteLine("OutputFile: {0}", opts.Out...
Console.WriteLine("Overwrite: {0}", opts.Over...
Else
'解析に失敗
Console.WriteLine("コマンドライン引数の解析に...
End If
Console.ReadLine()
End Sub
End Module
}}
#code(csharp){{
public class Program
{
//エントリポイント
static void Main(string[] args)
{
//Optionsクラスのインスタンスを作成
var opts = new Options();
//コマンドライン引数を解析する
bool isSuccess = CommandLine.Parser.Default.Parse...
if (isSuccess)
{
//解析に成功した時は、解析結果を表示
Console.WriteLine("OutputFile: {0}", opts.Out...
Console.WriteLine("Overwrite: {0}", opts.Over...
}
else
{
//解析に失敗
Console.WriteLine("コマンドライン引数の解析に...
}
Console.ReadLine();
}
}
}}
ParseArgumentsメソッドに、Mainメソッドのパラメータであるa...
はじめに示した
-o test.txt -v
というコマンドライン引数でこのアプリケーションを起動した...
コマンドライン引数に何も指定されなかった場合は、OutputFil...
#column(補足){{
Visual Studioのデバッグでコマンドライン引数を指定してプロ...
}}
ParseArgumentsメソッドがFalseを返した時は、解析に失敗した...
**長いコマンドラインオプション名 [#y321a393]
上記の例ではオプション名が一文字(Char型)でしたが、2文字...
次のようにOptionsクラスを変更すると、長い名前を使えるよう...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'短い名前と長い名前を両方を指定する
<CommandLine.Option("o"c, "output")> _
Public Property OutputFile As String
'長い名前だけを指定する
<CommandLine.Option("overwrite")> _
Public Property Overwrite As Boolean
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//短い名前と長い名前を両方を指定する
[CommandLine.Option('o', "output")]
public string OutputFile
{
get;
set;
}
//長い名前だけを指定する
[CommandLine.Option("overwrite")]
public bool Overwrite
{
get;
set;
}
}
}}
#column(補足){{
短い名前はChar型、長い名前はString型で指定しますが、1文字...
}}
#column(補足){{
長い名前にはダッシュやハイフンを含めることもできます。半...
}}
長いオプション名をコマンドライン引数に使う場合は、オプシ...
--output "C:\My Documents\test.txt" --overwrite
上記の例では、OutputFileは短い名前も有効ですので、次のよ...
-o "C:\My Documents\test.txt" --overwrite
長いオプション名を使った場合は、オプション名と値の区切り...
--output="C:\My Documents\test.txt" --overwrite
#column(補足){{
短い名前の前にもダッシュ(あるいはハイフン)を2つ付けるこ...
}}
ちなみに短い名前も長い名前も付けられていないプロパティは...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'"OutputFile"がコマンドラインオプションの長い名前になる
<CommandLine.Option> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//"OutputFile"がコマンドラインオプションの長い名前に...
[CommandLine.Option()]
public string OutputFile
{
get;
set;
}
}
}}
**コマンドライン引数の書き方 [#i0d22b61]
繰り返しになりますが、Command Line Parser Libraryが解析で...
コマンドは、まとめて記述することができます。例えば、
-vo test.txt
としたり、
-votest.txt
としたりすることもできます。
#column(補足){{
同じコマンドが2回記述された時は、後で記述されたものが優先...
}}
**必須のオプションを指定する [#p277851c]
必ずなければならない必須のオプションは、Option属性のRequi...
以下の例では、OutputFileを必須のオプションにしています。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'必須のオプションにする
<CommandLine.Option("o"c, "output", Required:=True)> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//必須のオプションにする
[CommandLine.Option('o', "output", Required=true)]
public string OutputFile
{
get;
set;
}
}
}}
**既定値を指定する [#m0c25aad]
オプションが指定されていなかった時の既定値を指定するには...
以下の例では、OutputFileの既定値を"test.txt"にしています。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'既定値を"test.txt"にする
<CommandLine.Option("o"c, DefaultValue:="test.txt")> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//既定値を"test.txt"にする
[CommandLine.Option('o', DefaultValue="test.txt")]
public string OutputFile
{
get;
set;
}
}
}}
**数値型や列挙型のオプション [#td390437]
上記の例ではオプションは文字列と論理値でしたが、数値や列...
以下に、整数型、Null許容型、列挙型のオプションの例を示し...
#code(vbnet){{
Public Enum FileType
Text
Html
Xml
End Enum
'オプションをプロパティに持つクラス
Public Class Options
'整数型のオプション
<CommandLine.Option("s"c)> _
Public Property Size As Integer
'浮動小数点型(Null許容型)のオプション
<CommandLine.Option("c"c)> _
Public Property Score As System.Nullable(Of Double)
'列挙型のオプション
<CommandLine.Option("t"c)> _
Public Property FileType As FileType
End Class
}}
#code(csharp){{
public enum FileType
{
Text,
Html,
Xml
}
//オプションをプロパティに持つクラス
public class Options
{
//整数型のオプション
[CommandLine.Option('s')]
public int Size
{
get;
set;
}
//浮動小数点型(Null許容型)のオプション
[CommandLine.Option('c')]
public double? Score
{
get;
set;
}
//列挙型のオプション
[CommandLine.Option('t')]
public FileType FileType
{
get;
set;
}
}
}}
列挙型のオプションの場合、コマンドライン引数でその値を指...
上記のクラスで正しく解析されるコマンドライン引数の例を示...
-s 100 -c 1E3 -t text
オプションで指定された文字列がそれに対応するプロパティの...
オプションが数値型の場合、指定された文字列が数値型に変換...
**配列やリストのオプション [#ge7d1468]
配列やリストのオプションも可能です。この場合は、Option属...
以下に、配列とリストのオプションの例を示します。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'配列のオプション
<CommandLine.OptionArray("n"c)> _
Public Property Numbers As Integer()
'リストのオプション
<CommandLine.OptionList("f"c, "files")> _
Public Property Files As IList(Of String)
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//配列のオプション
[CommandLine.OptionArray('n')]
public int[] Numbers
{
get;
set;
}
//リストのオプション
[CommandLine.OptionList('f', "files")]
public IList<string> Files
{
get;
set;
}
}
}}
#column(注意){{
OptionList属性を適用する場合は、短い名前と長い名前の両方...
}}
解析可能なコマンドライン引数は、例えば以下のようなもので...
-n 1 5 7 -f 1.txt:2.txt:3.txt
リストの区切り文字を変更するには、Separatorプロパティを使...
#code(vbnet){{
<CommandLine.OptionList("f"c, "files", Separator:=","c)> _
Public Property Files As IList(Of String)
}}
#code(csharp){{
[CommandLine.OptionList('f', "files", Separator=',')]
public IList<string> Files
{
get;
set;
}
}}
**オプション名のないリストを取得する [#bce1f089]
例えばコマンドライン引数が
1.txt 2.txt 3.txt
のようにオプション名が付いていない場合でも、その値をリス...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'String型のオプション
<CommandLine.Option("o"c, "output")> _
Public Property OutputFile As String
'オプション名がない値のリスト
<CommandLine.ValueList(GetType(List(Of String)))> _
Public Property InputFiles As IList(Of String)
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//String型のオプション
[CommandLine.Option('o', "output")]
public string OutputFile
{
get;
set;
}
//オプション名がない値のリスト
[CommandLine.ValueList(typeof(List<string>))]
public IList<string> InputFiles
{
get;
set;
}
}
}}
例えばコマンドライン引数が
-o test.txt 1.txt 2.txt 3.txt
だった場合、InputFilesプロパティには、"1.txt"、"2.txt"、"...
1.txt -o test.txt 2.txt 3.txt
のように順番が変わっても同じです。
#column(補足){{
コマンドライン引数に不明なオプション(文字列の先頭にダッ...
}}
ValueList属性は、MaximumElementsプロパティによって、最大...
#code(vbnet){{
'オプション名がない値のリスト
<CommandLine.ValueList(GetType(List(Of String)), MaximumE...
Public Property InputFiles As IList(Of String)
}}
#code(csharp){{
//オプション名がない値のリスト
[CommandLine.ValueList(typeof(List<string>), MaximumEleme...
public IList<string> InputFiles
{
get;
set;
}
}}
この状態でコマンドライン引数を
-o test.txt 1.txt 2.txt 3.txt
とすると、ParseArgumentsメソッドがFalseを返し、InputFiles...
**次回予告 [#lb6c1405]
まだまだ紹介したい機能がありますが、今回はこれまでとさせ...
**コメント [#u7f6559a]
- ParseArguments(IEnumerable<string> args, params Type[] ...
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2013-0...
終了行:
#title(Command Line Parser Libraryを使ってコマンドライン...
#navi(.NETプログラミング研究)
#contents
*Command Line Parser Libraryを使ってコマンドライン引数を...
アプリケーションを起動する時に指定されたコマンドライン引...
コマンドライン引数を解析するためのフリーのクラスやライブ...
**Command Line Parser Libraryをインストールする [#t1338ee6]
***NuGetを使った方法 [#bcbcb8fa]
Command Line Parser Libraryは[[NuGet>http://nuget.codeple...
&embed(<a href="https://www.flickr.com/photos/dobondotnet...
もしVisual Studio 2010未満でNuGetがインストールできないの...
Visual Studio 2010以上でNuGetがインストールされているなら...
+Command Line Parser Libraryを使用するプロジェクトをVisua...
+メニューの[ツール]-[プロジェクト]-[NuGetパッケージの管理...
+ダイアログの左側で「オンライン」を選択し、右上の「オンラ...
+見つかった「Command Line Parser Library」を選択して、「...
このようなダイアログを使わずに、パッケージマネージャーコ...
PM> Install-Package CommandLineParser
***バイナリをダウンロードする方法 [#r7c3a110]
NuGetを使わずに、バイナリを直接ダウンロードしてインストー...
**Command Line Parser Libraryが解析できるコマンドライン引...
Command Line Parser Libraryが解析できるコマンドライン引数...
例えば、
-o test.txt -v
というコマンドライン引数を解析することはできますが、
/o test.txt /v
というものは解析できません。
**簡単な使い方 [#z240b773]
それでは早速使ってみましょう。
ここでは、"o"と"v"2つのオプションを定義することで、例えば
-o test.txt -v
というコマンドライン引数を、
「"o"オプションには"test.txt"が指定されていて、"v"オプシ...
と解析できるようにします。
まずコンソールアプリケーションのプロジェクトを作成して、...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'String型のオプション
<CommandLine.Option("o"c)> _
Public Property OutputFile As String
'Boolean型のオプション
<CommandLine.Option("v"c)> _
Public Property Overwrite As Boolean
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//String型のオプション
[CommandLine.Option('o')]
public string OutputFile
{
get;
set;
}
//Boolean型のオプション
[CommandLine.Option('v')]
public bool Overwrite
{
get;
set;
}
}
}}
このクラスにはOption属性が適用されたプロパティが2つありま...
#column(補足){{
プロパティには、GetとSetの両方が必要です。Getだけではエラ...
}}
次に、解析結果を取得するためのコードを記述します。これは...
#code(vbnet){{
Module Module1
'エントリポイント
Sub Main(args As String())
'Optionsクラスのインスタンスを作成
Dim opts = New Options()
'コマンドライン引数を解析する
Dim isSuccess As Boolean = _
CommandLine.Parser.Default.ParseArguments(arg...
If isSuccess Then
'解析に成功した時は、解析結果を表示
Console.WriteLine("OutputFile: {0}", opts.Out...
Console.WriteLine("Overwrite: {0}", opts.Over...
Else
'解析に失敗
Console.WriteLine("コマンドライン引数の解析に...
End If
Console.ReadLine()
End Sub
End Module
}}
#code(csharp){{
public class Program
{
//エントリポイント
static void Main(string[] args)
{
//Optionsクラスのインスタンスを作成
var opts = new Options();
//コマンドライン引数を解析する
bool isSuccess = CommandLine.Parser.Default.Parse...
if (isSuccess)
{
//解析に成功した時は、解析結果を表示
Console.WriteLine("OutputFile: {0}", opts.Out...
Console.WriteLine("Overwrite: {0}", opts.Over...
}
else
{
//解析に失敗
Console.WriteLine("コマンドライン引数の解析に...
}
Console.ReadLine();
}
}
}}
ParseArgumentsメソッドに、Mainメソッドのパラメータであるa...
はじめに示した
-o test.txt -v
というコマンドライン引数でこのアプリケーションを起動した...
コマンドライン引数に何も指定されなかった場合は、OutputFil...
#column(補足){{
Visual Studioのデバッグでコマンドライン引数を指定してプロ...
}}
ParseArgumentsメソッドがFalseを返した時は、解析に失敗した...
**長いコマンドラインオプション名 [#y321a393]
上記の例ではオプション名が一文字(Char型)でしたが、2文字...
次のようにOptionsクラスを変更すると、長い名前を使えるよう...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'短い名前と長い名前を両方を指定する
<CommandLine.Option("o"c, "output")> _
Public Property OutputFile As String
'長い名前だけを指定する
<CommandLine.Option("overwrite")> _
Public Property Overwrite As Boolean
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//短い名前と長い名前を両方を指定する
[CommandLine.Option('o', "output")]
public string OutputFile
{
get;
set;
}
//長い名前だけを指定する
[CommandLine.Option("overwrite")]
public bool Overwrite
{
get;
set;
}
}
}}
#column(補足){{
短い名前はChar型、長い名前はString型で指定しますが、1文字...
}}
#column(補足){{
長い名前にはダッシュやハイフンを含めることもできます。半...
}}
長いオプション名をコマンドライン引数に使う場合は、オプシ...
--output "C:\My Documents\test.txt" --overwrite
上記の例では、OutputFileは短い名前も有効ですので、次のよ...
-o "C:\My Documents\test.txt" --overwrite
長いオプション名を使った場合は、オプション名と値の区切り...
--output="C:\My Documents\test.txt" --overwrite
#column(補足){{
短い名前の前にもダッシュ(あるいはハイフン)を2つ付けるこ...
}}
ちなみに短い名前も長い名前も付けられていないプロパティは...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'"OutputFile"がコマンドラインオプションの長い名前になる
<CommandLine.Option> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//"OutputFile"がコマンドラインオプションの長い名前に...
[CommandLine.Option()]
public string OutputFile
{
get;
set;
}
}
}}
**コマンドライン引数の書き方 [#i0d22b61]
繰り返しになりますが、Command Line Parser Libraryが解析で...
コマンドは、まとめて記述することができます。例えば、
-vo test.txt
としたり、
-votest.txt
としたりすることもできます。
#column(補足){{
同じコマンドが2回記述された時は、後で記述されたものが優先...
}}
**必須のオプションを指定する [#p277851c]
必ずなければならない必須のオプションは、Option属性のRequi...
以下の例では、OutputFileを必須のオプションにしています。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'必須のオプションにする
<CommandLine.Option("o"c, "output", Required:=True)> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//必須のオプションにする
[CommandLine.Option('o', "output", Required=true)]
public string OutputFile
{
get;
set;
}
}
}}
**既定値を指定する [#m0c25aad]
オプションが指定されていなかった時の既定値を指定するには...
以下の例では、OutputFileの既定値を"test.txt"にしています。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'既定値を"test.txt"にする
<CommandLine.Option("o"c, DefaultValue:="test.txt")> _
Public Property OutputFile As String
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//既定値を"test.txt"にする
[CommandLine.Option('o', DefaultValue="test.txt")]
public string OutputFile
{
get;
set;
}
}
}}
**数値型や列挙型のオプション [#td390437]
上記の例ではオプションは文字列と論理値でしたが、数値や列...
以下に、整数型、Null許容型、列挙型のオプションの例を示し...
#code(vbnet){{
Public Enum FileType
Text
Html
Xml
End Enum
'オプションをプロパティに持つクラス
Public Class Options
'整数型のオプション
<CommandLine.Option("s"c)> _
Public Property Size As Integer
'浮動小数点型(Null許容型)のオプション
<CommandLine.Option("c"c)> _
Public Property Score As System.Nullable(Of Double)
'列挙型のオプション
<CommandLine.Option("t"c)> _
Public Property FileType As FileType
End Class
}}
#code(csharp){{
public enum FileType
{
Text,
Html,
Xml
}
//オプションをプロパティに持つクラス
public class Options
{
//整数型のオプション
[CommandLine.Option('s')]
public int Size
{
get;
set;
}
//浮動小数点型(Null許容型)のオプション
[CommandLine.Option('c')]
public double? Score
{
get;
set;
}
//列挙型のオプション
[CommandLine.Option('t')]
public FileType FileType
{
get;
set;
}
}
}}
列挙型のオプションの場合、コマンドライン引数でその値を指...
上記のクラスで正しく解析されるコマンドライン引数の例を示...
-s 100 -c 1E3 -t text
オプションで指定された文字列がそれに対応するプロパティの...
オプションが数値型の場合、指定された文字列が数値型に変換...
**配列やリストのオプション [#ge7d1468]
配列やリストのオプションも可能です。この場合は、Option属...
以下に、配列とリストのオプションの例を示します。
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'配列のオプション
<CommandLine.OptionArray("n"c)> _
Public Property Numbers As Integer()
'リストのオプション
<CommandLine.OptionList("f"c, "files")> _
Public Property Files As IList(Of String)
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//配列のオプション
[CommandLine.OptionArray('n')]
public int[] Numbers
{
get;
set;
}
//リストのオプション
[CommandLine.OptionList('f', "files")]
public IList<string> Files
{
get;
set;
}
}
}}
#column(注意){{
OptionList属性を適用する場合は、短い名前と長い名前の両方...
}}
解析可能なコマンドライン引数は、例えば以下のようなもので...
-n 1 5 7 -f 1.txt:2.txt:3.txt
リストの区切り文字を変更するには、Separatorプロパティを使...
#code(vbnet){{
<CommandLine.OptionList("f"c, "files", Separator:=","c)> _
Public Property Files As IList(Of String)
}}
#code(csharp){{
[CommandLine.OptionList('f', "files", Separator=',')]
public IList<string> Files
{
get;
set;
}
}}
**オプション名のないリストを取得する [#bce1f089]
例えばコマンドライン引数が
1.txt 2.txt 3.txt
のようにオプション名が付いていない場合でも、その値をリス...
#code(vbnet){{
'オプションをプロパティに持つクラス
Public Class Options
'String型のオプション
<CommandLine.Option("o"c, "output")> _
Public Property OutputFile As String
'オプション名がない値のリスト
<CommandLine.ValueList(GetType(List(Of String)))> _
Public Property InputFiles As IList(Of String)
End Class
}}
#code(csharp){{
//オプションをプロパティに持つクラス
public class Options
{
//String型のオプション
[CommandLine.Option('o', "output")]
public string OutputFile
{
get;
set;
}
//オプション名がない値のリスト
[CommandLine.ValueList(typeof(List<string>))]
public IList<string> InputFiles
{
get;
set;
}
}
}}
例えばコマンドライン引数が
-o test.txt 1.txt 2.txt 3.txt
だった場合、InputFilesプロパティには、"1.txt"、"2.txt"、"...
1.txt -o test.txt 2.txt 3.txt
のように順番が変わっても同じです。
#column(補足){{
コマンドライン引数に不明なオプション(文字列の先頭にダッ...
}}
ValueList属性は、MaximumElementsプロパティによって、最大...
#code(vbnet){{
'オプション名がない値のリスト
<CommandLine.ValueList(GetType(List(Of String)), MaximumE...
Public Property InputFiles As IList(Of String)
}}
#code(csharp){{
//オプション名がない値のリスト
[CommandLine.ValueList(typeof(List<string>), MaximumEleme...
public IList<string> InputFiles
{
get;
set;
}
}}
この状態でコマンドライン引数を
-o test.txt 1.txt 2.txt 3.txt
とすると、ParseArgumentsメソッドがFalseを返し、InputFiles...
**次回予告 [#lb6c1405]
まだまだ紹介したい機能がありますが、今回はこれまでとさせ...
**コメント [#u7f6559a]
- ParseArguments(IEnumerable<string> args, params Type[] ...
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2013-0...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]