没有返回值的VB.NET函数,转换为C#获取返回错误?

没有返回值的VB.NET函数,转换为C#获取返回错误?,c#,.net,vb.net,translate,C#,.net,Vb.net,Translate,转换一些VB.NET代码。一些静态函数对通过引用传递的某些参数执行一些操作,但不返回任何内容。在VB.NET函数中到底发生了什么,它们可以存在而不具有返回值,并且不会得到任何调试错误?布尔值会发生什么变化 Overloads Shared Function ExampleMethod(ByRef buffer1() as Byte, ByRef buffer2() as Byte) As Boolean 'do stuff here, no return types End Function

转换一些VB.NET代码。一些静态函数对通过引用传递的某些参数执行一些操作,但不返回任何内容。在VB.NET函数中到底发生了什么,它们可以存在而不具有返回值,并且不会得到任何调试错误?布尔值会发生什么变化

Overloads Shared Function ExampleMethod(ByRef buffer1() as Byte, ByRef buffer2() as Byte) As Boolean
'do stuff here, no return types
End Function

Overloads Shared Function ExampleMethod(ByRef buffer1() as Byte, ByRef buffer2 as Byte) As Boolean
'do stuff here, no return types
End Function

使用VB.Net,您可以通过使用
return
语句或为函数名赋值来返回值,例如:

    ExampleMethod = true
    Exit Function
End Function
它接着说:

如果使用Exit函数而不为name赋值,则过程将返回returntype中指定的数据类型的默认值。如果未指定returntype,则过程将不返回任何内容,这是对象的默认值


C#更严格一点

如果我错了,请纠正我,
As Boolean
表示返回
Boolean
?你也可以在这篇文章中选择ByRef: