G
Guest
I am a VB programmer tring to learn C#
I am stuck on a bit operator "&"
in VB:
' checkLogin = 3 means "Login exists" and "Employee Number exists"
If (checkLogin And 1) Then
lbError.Text = "Login already exists"
End If
If (checkLogin And 2) And txtEmpNum.Text <> 0 Then
lbError.Text &= "Employee Number already exists"
End If
I did this in C#:
if(checkLogin & 1)
{
lbError.Text = "Login already exists";
}
if((checkLogin & 2) & txtEmpNum.Text.Length > 0 )
{
lbError.Text = "Employee Number already exists";
}
Error:
Cannot implicitly convert type 'int' to 'bool'
--
Thanks in advance,
Dave
Sorry for the cross post, I selected the wrong group
I am stuck on a bit operator "&"
in VB:
' checkLogin = 3 means "Login exists" and "Employee Number exists"
If (checkLogin And 1) Then
lbError.Text = "Login already exists"
End If
If (checkLogin And 2) And txtEmpNum.Text <> 0 Then
lbError.Text &= "Employee Number already exists"
End If
I did this in C#:
if(checkLogin & 1)
{
lbError.Text = "Login already exists";
}
if((checkLogin & 2) & txtEmpNum.Text.Length > 0 )
{
lbError.Text = "Employee Number already exists";
}
Error:
Cannot implicitly convert type 'int' to 'bool'
--
Thanks in advance,
Dave
Sorry for the cross post, I selected the wrong group