如何在VB.NET中获取Main方法的参数 [英] How to get arguments of Main method in VB.NET

查看:40
本文介绍了如何在VB.NET中获取Main方法的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 控制台应用程序中,Main 方法有一个 string() 参数,但在 VB.NET 中,Main 方法不包含该参数,如果我设置了命令行参数,如何检索它们?

In C# Console Application, Main method has a string() argument, but in VB.NET, the Main method doesn't contain the argument, if I set command line arguments, how to retrieve them?

在 C# 中,如果我右键单击项目并选择属性,在调试项中设置命令行参数,我可以使用 args[0]、args[1] 等来实现我的参数.在VB.NET中,我发现

In C#, if I right click the project and select Properties, set command line arguments in debug item, I can use args[0], args[1] and so on to achive my arguments. In VB.NET, I found

System.Environment.GetCommandLineArgs()

也可以实现,但是多了一个参数,还包含了进程的路径,谁能帮帮忙?

can also achive them, but it contains one more argument, it also contains the path of the process, anyone can help?

推荐答案

您可以将它们添加到入口点方法签名 (ByVal args() As String) 并像在C#.您还可以使用 VB.NETs My 类来访问它们,例如 My.Application.CommandLineArgs.

You could add them to the entry point method signature (ByVal args() As String) and access them just as you would in C#. You could also use VB.NETs My class to access them such as My.Application.CommandLineArgs.

这篇关于如何在VB.NET中获取Main方法的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆