我有一个通过引用接受字符串的函数:
Function Foo(ByRef input As String)
如果我这样称呼它:
Foo(Nothing)
我希望它做一些不同于我这样称呼它的事情:
Dim myString As String = Nothing
Foo(myString)
是否可以在 VB .NET 中调用该方法的方式检测到这种差异?
编辑
为了澄清我为什么要这样做,我有两种方法:
Function Foo()
Foo(Nothing)
End Function
Function Foo(ByRef input As String)
'wicked awesome logic here, hopefully
End Function
Nothing
所有逻辑都在第二个重载中,但是如果传入函数而不是传入包含 的变量,我想执行不同的逻辑分支Nothing
。