Bra*_*ery 4 vb.net null pass-by-reference nothing
我有一个通过引用接受String的函数:
Function Foo(ByRef input As String)
Run Code Online (Sandbox Code Playgroud)
如果我这样称呼它:
Foo(Nothing)
Run Code Online (Sandbox Code Playgroud)
我想要它做一些不同的事情,如果我这样称呼它:
Dim myString As String = Nothing
Foo(myString)
Run Code Online (Sandbox Code Playgroud)
是否有可能在VB .NET中调用方法的方式中检测到这种差异?
编辑
为了澄清为什么我想要这样做,我有两种方法:
Function Foo()
Foo(Nothing)
End Function
Function Foo(ByRef input As String)
'wicked awesome logic here, hopefully
End Function
Run Code Online (Sandbox Code Playgroud)
所有逻辑都在第二个重载中,但是如果Nothing传递给函数,我想执行不同的逻辑分支,而不是传入包含 的变量Nothing.
| 归档时间: |
|
| 查看次数: |
4124 次 |
| 最近记录: |