How is this VB.NET code being evaluated?
I am working on converting code from VB.NET to C #. I found this piece of code that I'm trying to wrap around myself, but I can't figure out how it is evaluated:
If eToken.ToLower = False Then _
Throw New Exception("An eToken is required for this kind of VPN-Permission.)
My problem is comparing a string eToken.ToLower
against a boolean False
.
I tried to use a converter and what I got was this: (which is not a valid expression in C # as you cannot compare string
with bool
):
if (eToken.ToLower() == false) {
throw new Exception("An eToken is required for this kind of VPN-Permission.");
}
source to share
I have compiled it and decompiled IL; in C # which:
string eToken = "abc"; // from: Dim eToken As String = "abc" in my code
if (!Conversions.ToBoolean(eToken.ToLower()))
{
throw new Exception("An eToken is required for this kind of VPN-Permission.");
}
So your answer is: it uses Conversions.ToBoolean
(where Conversions
is Microsoft.VisualBasic.CompilerServices.Conversions
in Microsoft.VisualBasic.dll
)
source to share