Setting userAccountControl Property

I am rewriting a VB app in C#, and this line of code is cauing me problems...

VB:

newUser.Properties("userAccountControl").Value = userACFlags Or &H200 Or &H10000 Xor &H2

C#:

newUser.Properties["userAccountControl"].Value = userACFlags || &H200 || &H10000 ^ &H2;

All of the "&H" values generate an error "not in the namespace." What should these be set to? (JHenry, I know you're out there, so please help.)

Jim
jawhitmoyerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Try

newUser.Properties["userAccountControl"].Value = userACFlags || 0x200 || 0x10000 ^ 0x2;
jawhitmoyerAuthor Commented:
That did fix the hex problem, but this generates an error:

object userACFlags = newUser.Properties["userAccountControl"].Value;
                  newUser.Properties["userAccountControl"].Value = userACFlags || 0x200 || 0x10000 ^ 0x2;

Operator || cannot be applied to objects and int.

Any thoughts?
Fernando SotoRetiredCommented:
Sorry it should be bitwise Or operator

newUser.Properties["userAccountControl"].Value = userACFlags | 0x200 | 0x10000 ^ 0x2;
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

jawhitmoyerAuthor Commented:
Tried that, too. But same error.

Operator '|' cannot be applied to operands of type 'object' and 'int'

Should I set userACFlags to some other type?
DaHaCommented:
Yes, userACFlags should be a numeric type, int should be fine for that job here.
Fernando SotoRetiredCommented:
Yes to int

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jawhitmoyerAuthor Commented:
That was it...I was just trying that here. Gotta love Experts Exchange and MSDN.

Enjoy the 4th!
Fernando SotoRetiredCommented:
Thank you, and you have a great 4th of July as well. :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.