The C# equivalent to "Or" is "|" (single pipe).
The C# equivalent to "And" is "&" (single ampersand).
"|" and "&" are the bitwise operators (and non-short-circuit logical
operators) in C#.
It's only "OrElse" that converts to "||" and "AndAlso" that converts to "&&".
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter
"ano" wrote:
> Hi,
>
> I have converted this VB code to C# but I got this error:
> "Operator '||' cannot be applied to operands of type 'int' and 'short'"
>
> Is VB allow to use Operator "Or" with 'int'?
> If yes, how to do this in c#?
>
> Thanks,
>
> VB:
>
> Private Const SERVICE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or
> SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or
> SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or
> SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL)
>
> Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
> Private Const SC_MANAGER_CONNECT = &H1
> Private Const SC_MANAGER_CREATE_SERVICE = &H2
> Private Const SC_MANAGER_ENUMERATE_SERVICE = &H4
> Private Const SC_MANAGER_LOCK = &H8
> Private Const SC_MANAGER_QUERY_LOCK_STATUS = &H10
> Private Const SC_MANAGER_MODIFY_BOOT_CONFIG = &H20
>
>
> C#
>
> private const int SERVICE_ALL_ACCESS = ( STANDARD_RIGHTS_REQUIRED ||
> SERVICE_QUERY_CONFIG ||
> SERVICE_CHANGE_CONFIG ||
> SERVICE_QUERY_STATUS ||
>
> SERVICE_ENUMERATE_DEPENDENTS ||
> SERVICE_START ||
> SERVICE_STOP ||
> SERVICE_PAUSE_CONTINUE ||
> SERVICE_INTERROGATE ||
>
> SERVICE_USER_DEFINED_CONTROL );
>
> Private Const STANDARD_RIGHTS_REQUIRED = 0xF0000
> Private Const SC_MANAGER_CONNECT = 0x1
> Private Const SC_MANAGER_CREATE_SERVICE = 0x2
> Private Const SC_MANAGER_ENUMERATE_SERVICE = 0x4
> Private Const SC_MANAGER_LOCK = 0x8
> Private Const SC_MANAGER_QUERY_LOCK_STATUS = 0x10
> Private Const SC_MANAGER_MODIFY_BOOT_CONFIG = 0x20