Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. And operator in c#?

And operator in c#?

Scheduled Pinned Locked Moved C#
csharphelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CopperCircle
    wrote on last edited by
    #1

    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.

    G N 2 Replies Last reply
    0
    • C CopperCircle

      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.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • C CopperCircle

        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.

        N Offline
        N Offline
        nelsonpaixao
        wrote on last edited by
        #3

        And = && Or = ||

        nelsonpaixao@yahoo.com.br

        D 1 Reply Last reply
        0
        • N nelsonpaixao

          And = && Or = ||

          nelsonpaixao@yahoo.com.br

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups