vb.net 没有返回类型的函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4518131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:12:49  来源:igfitidea点击:

Function without return type

vb.netfunction

提问by sventevit

In my project (which I inherited from someone) there are a lot of functions like:

在我的项目中(我从某人那里继承来的)有很多功能,例如:

Public Function DoSomething(ByVal s As String)
    ' Do something to public properties
End Function

And they are called like this:

他们是这样称呼的:

DoSomething(s)

So the return value is ignored (which is object, as I see in the docs). Is it safe to change all these functions to Subs? Could I break something which isn't so obvious?

所以返回值被忽略(这是对象,正如我在文档中看到的那样)。将所有这些功能更改为 Subs 是否安全?我可以打破一些不太明显的东西吗?

回答by Jules

Should be safe. That's what Subs are for, this is really bad style by your predecessor.

应该是安全的。这就是 Subs 的用途,这真是你前任的糟糕风格。

回答by m.edmondson

Is there any specific reason you want to convert to Subs? From your code the Function has no return type- in this situation I can't see there being any problem.

您是否有任何特定原因要转换为 Subs?从您的代码中 Function没有返回类型- 在这种情况下,我看不出有任何问题。