简体   繁体   中英

Convert from VB to C#

I want to translate these line of code from VB.NET to C# and when I check online from

If (userAccountControl And 65536) Then
                                        Dont_Expire_Password = 1
                                  Else
                                        Dont_Expire_Password = 0
                                  End If

Link 1

Link 2

I get something

 if (userAccountControl & 65536)
    {
    }

But I get error in

Cannot implicitly convert type 'int' to 'bool'

I assume this mean

if (userAccountControl == 65536)

Correct me if I am wrong !

In C# int doesn't implicitly convert to a bool , so you need to write your expression to handle this. In your case it would be:

if((userAccountControl & 65536) != 0)
{
  // Do something
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM