There is absolutely no point (that I can think of, anyway) to doing this, buuut…
We all know about
ReferenceEquals, right? Look at two variables, see if they reference the same object instance?
Dim x As New Object Dim y As Object = x Console.WriteLine(ReferenceEquals(x, y))
The above code will output
True. Well, can you think of a way to write a
VariableEquals method that will only return
True if the same variable is passed in for both parameters?
In other words, given the hypothetical
VariableEquals method I just described:
Dim x As Integer = 5 Dim y As Integer = x Console.WriteLine(VariableEquals(x, y)) Console.WriteLine(VariableEquals(x, x))
…the above code should output
Yes, it is possible! (Hints below—highlight the text if you want to see them.)
Hint 2: I am not guaranteeing the solution can actually be written in VB.NET, mind you.
Again, there is no point to this. I’m just a tinkerer, so I personally love this sort of stuff.