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. Bug of the Day

Bug of the Day

Scheduled Pinned Locked Moved The Lounge
help
47 Posts 17 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.
  • I Ian Shlasko

    He's basically doing this:

    "1_2" + '_' + 3

    Note that the underscore is a character, not a string (Single quotes = char, Double quotes = string). So instead of both parts being converted to strings to form "_3", it's treating the character as a number (ASCII code 95), adding 3 to it, THEN converting it to a string... So it becomes "1_2" + "98" Very subtle. I like it.

    Proud to have finally moved to the A-Ark. Which one are you in?
    Author of the Guardians Saga (Sci-Fi/Fantasy novels)

    B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #38

    Subtle indeed. I never use char literals unless absolutely necessary. A one char string is a tad expensive in some cases, but surely not in this one.

    Follow my adventures with .NET Core at my new blog, Erisia Information Services.

    1 Reply Last reply
    0
    • J Jeremy Falcon

      Sander Rossel wrote:

      Having said that, JavaScript DOES have types. It has strings, numbers, booleans null, undefined and objects...Why do you persist that JavaScript has no types when the opposite is obviously true?

      :sigh: Might wanna read what I wrote.

      Sander Rossel wrote:

      I'm just human and I won't pass on a chance to bitch about JavaScript.

      Fair enough, but as a human, may I humbly suggest you get a woman to occupy your time. ;P

      Jeremy Falcon

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #39

      Just "getting" a woman is not like just getting a Coke.

      Follow my adventures with .NET Core at my new blog, Erisia Information Services.

      1 Reply Last reply
      0
      • F Foothill

        I thought that I was the only one who still uses GIMP. ;)

        if (Object.DividedByZero == true) { Universe.Implode(); } Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #40

        Yeah, GIMP's no big deal. There's nothing I can't draw with AutoCad, Paint.NET, and InkScape.

        Follow my adventures with .NET Core at my new blog, Erisia Information Services.

        1 Reply Last reply
        0
        • C Chris Maunder

          When you say "thread view" do you mean that you were kicked into a different default view on the forums? We did a hefty refactor this week to clean up some debris from 4 years ago. We tested the blazes out of it but no matter what you test you'll always miss something. Unless you're NASA.

          cheers Chris Maunder

          B Offline
          B Offline
          Brady Kelly
          wrote on last edited by
          #41

          NASA has historically missed quite a lot, even idiotic things like metric vs. imperial confusion.

          Follow my adventures with .NET Core at my new blog, Erisia Information Services.

          1 Reply Last reply
          0
          • C Chris Maunder

            Which CSS?

            cheers Chris Maunder

            Z Offline
            Z Offline
            ZurdoDev
            wrote on last edited by
            #42

            See post below for screenshot, The Lounge[^]. Chrome on linux and win10 for me. The whole screen stretches out and font was smaller.

            There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.

            1 Reply Last reply
            0
            • C Chris Maunder

              Enlighten us.

              cheers Chris Maunder

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #43

              I'm not sure at all, but I try to give you some Feedback as soon I can deliver some real info. It seems also some A in Q&A disappeared... Even if I'm uncomfortable, I'm just trying to help :(

              1 Reply Last reply
              0
              • C Chris Maunder

                string objectRefGuid = objectRef.ObjectTypeId.ToString() + PartDivider + objectRef.ObjectId;

                if (objectRef.VersionNumber > 0)
                objectRefGuid += PartDivider + objectRef.VersionNumber;

                ObjectTypeId is 1, ObjectId is 2, and VersionNumber is 3. PartDivider is '_'. The expected result was 1_2_3. The output was 1_298. :doh:

                cheers Chris Maunder

                M Offline
                M Offline
                Mario Z
                wrote on last edited by
                #44

                Brady Kelly wrote:

                Subtle indeed. I never use char literals unless absolutely necessary. A one char string is a tad expensive in some cases, but surely not in this one.

                I agree with that. Also to me it seems that PartDivider is meant for only formatting purposes (judging from the name itself, aka it's meant for interpolation or concatenation purposes) so it seems kind-of intuitive to specify it as string. Nevertheless in this kind of cases I always prefer using interpolated (if you can use a higher C# version) or formattable strings, for example:

                private const string ObjectRefGuidFormat = "{0}{1:_0}{2:_0}";

                // ...

                // E.g. "1_2" or "1_2_3".
                string objectRefGuid = string.Format(ObjectRefGuidFormat,
                objectRef.ObjectTypeId,
                objectRef.ObjectId,
                objectRef.VersionNumber > 0 ? objectRef.VersionNumber.ToString() : null);

                1 Reply Last reply
                0
                • Sander RosselS Sander Rossel

                  You know I can't sit around idle when people on the internet say bad things about my favorite programming language. Or positive things about my least favorite programming language. I'm just human and I won't pass on a chance to bitch about JavaScript. Having said that, JavaScript DOES have types. It has strings, numbers, booleans null, undefined and objects... Why do you persist that JavaScript has no types when the opposite is obviously true? ;p

                  Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #45

                  mandatory xkcd: Duty Calls[^]

                  M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                  1 Reply Last reply
                  0
                  • J Jeremy Falcon

                    And obligatory XKCD :) xkcd: Duty Calls[^]

                    Jeremy Falcon

                    N Offline
                    N Offline
                    Nelek
                    wrote on last edited by
                    #46

                    I was reading the thread and had exact the same idea... but then I saw your post :sigh: :sigh:

                    M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                    1 Reply Last reply
                    0
                    • B Bryian Tan

                      I'm curious, do you know why it end up 1_298?

                      C Offline
                      C Offline
                      Chris Maunder
                      wrote on last edited by
                      #47

                      I'm adding a char and an int and adding that to a string. If it was string + char + int it would all be good, but it's string += char + int whichh gets implicitly cast to string += (string)(int + int). (int) '_' = 95, so '_' + 3 = 98. we get "1_2" + "98" = "1_298"

                      cheers Chris Maunder

                      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