And operator in c#?
-
Hi, I am trying to convert some of my BlitzBasic code over to C# and I cant get the following statment to work? Blitz: If paletteRmap[i]=0 And paletteGmap[i]=0 And paletteBmap[i]=0 C#: If (paletteRmap[best]=0 & paletteGmap[best]=0 & paletteBmap[best]=0) Error Message The left-hand side of an assignment must be a variable, property or indexer? Thanks.
-
Hi, I am trying to convert some of my BlitzBasic code over to C# and I cant get the following statment to work? Blitz: If paletteRmap[i]=0 And paletteGmap[i]=0 And paletteBmap[i]=0 C#: If (paletteRmap[best]=0 & paletteGmap[best]=0 & paletteBmap[best]=0) Error Message The left-hand side of an assignment must be a variable, property or indexer? Thanks.
You are looking at the wrong operator for the error. The equality comparison operator in C# is ==, not =. However, you probably want to use the regular && operator that does short-cut evaluation, instead of the & operator that always evaluates both operands, regardless if it's needed to determine the result of the operation.
if (paletteRmap[best] == 0 && paletteGmap[best] == 0 && paletteBmap[best] == 0)
Despite everything, the person most likely to be fooling you next is yourself.
-
Hi, I am trying to convert some of my BlitzBasic code over to C# and I cant get the following statment to work? Blitz: If paletteRmap[i]=0 And paletteGmap[i]=0 And paletteBmap[i]=0 C#: If (paletteRmap[best]=0 & paletteGmap[best]=0 & paletteBmap[best]=0) Error Message The left-hand side of an assignment must be a variable, property or indexer? Thanks.
And = && Or = ||
-
And = && Or = ||
And = & (bitwise 'and') Or = | (bitwise 'or') AndAlso = && (logical 'and') OrElse = || (logical 'or') You'll get into problems replacing the bitwise 'And' and 'Or' operators with the logical && and || operators. Conversion problems from VB are caused by the fact that many VB programmers misuse 'And' and 'Or' as logical operators (they will function as non-short-circuiting logical operators, but are designed to be bitwise operators).
David Anton http://www.tangiblesoftwaresolutions.com C++ to C# Converter C++ to VB Converter C++ to Java Converter VB & C# to Java Converter Java to VB & C# Converter Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: convert VB, C#, or Java to C++/CLI