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. The Lounge
  3. C# syntax quiz [modified*2]

C# syntax quiz [modified*2]

Scheduled Pinned Locked Moved The Lounge
questioncsharp
22 Posts 6 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.
  • P PIEBALDconsult

    Daniel Grunwald wrote:

    i =+ +j;

    What's that? It's not +=

    D Offline
    D Offline
    Daniel Grunwald
    wrote on last edited by
    #21

    "i =+ +j;" is the same as "i = +(+j);" - it's using the unary plus operator two times.

    1 Reply Last reply
    0
    • D Daniel Grunwald

      It's easy with unary plus/minus <-> increment/decrement:

      i =+ +j;
      x = y - -5 ;

      But there is another solution that's much more difficult to find:

      object o = null;
      string text = o is int ? ? "o is Nullable" : "o is not Nullable";

      Removing the space between the question marks causes them to become the null-coalescing operator ??, and you get a syntax error at the ':'.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #22

      Just goes to show that one should always give one's operators room to breathe.

      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