在 vb.net 中获取命令行参数的最佳方法是什么

What is the best way for grabbing command line arguments in vb.net

我在 C# 中做过几次,但是对于 vb.net 我是按如下方式使用 My.Application.CommandLineArgs 还是有更好的方法?

Dim argListArray As New ArrayList

For Each argument As String In My.Application.CommandLineArgs
    argListArray.Add(argument)
Next

If argListArray.Count = 5 Then
    ImageName = argListArray(0).ToString            
    ImageAddress = argListArray(1).ToString 
    ImagePort = argListArray(2).ToString 
    FileLoc = argListArray(3).ToString 
    JPEGQuality = argListArray(4).ToString  
Else
    'TODO invalid # args

End If

同意...直接使用My.Application.CommandLineArgs:

    If My.Application.CommandLineArgs.Count = 5 Then
        ImageName = My.Application.CommandLineArgs(0)
        ImageAddress = My.Application.CommandLineArgs(1)
        ImagePort = My.Application.CommandLineArgs(2)
        FileLoc = My.Application.CommandLineArgs(3)
        JPEGQuality = My.Application.CommandLineArgs(4)
    Else
        ' TODO invalid # args
    End If