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. Other Discussions
  3. The Weird and The Wonderful
  4. Type conversion

Type conversion

Scheduled Pinned Locked Moved The Weird and The Wonderful
comquestion
8 Posts 7 Posters 2 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.
  • W Offline
    W Offline
    WillemM
    wrote on last edited by
    #1

    The actual code is a bit different, but the essence was that the developer who wrote it screwed up big time. Converting string to string is a bit useless in my humble opinion ;P

    void SaveUserText(string userText) {
        string text = userText.ToString();
    }
    

    WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

    C P 2 Replies Last reply
    0
    • W WillemM

      The actual code is a bit different, but the essence was that the developer who wrote it screwed up big time. Converting string to string is a bit useless in my humble opinion ;P

      void SaveUserText(string userText) {
          string text = userText.ToString();
      }
      

      WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      I suprised that there isn't an assert there as well. :)

      void SaveUserText(string userText)
      {
      string text = userText.ToString();
      assert ( text == userText );
      }

      Chris Meech I am Canadian. [heard in a local bar]

      P 1 Reply Last reply
      0
      • C Chris Meech

        I suprised that there isn't an assert there as well. :)

        void SaveUserText(string userText)
        {
        string text = userText.ToString();
        assert ( text == userText );
        }

        Chris Meech I am Canadian. [heard in a local bar]

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Surely that would be

        void SaveUserText(string userText)
        {    
            string text = userText.ToString();
            assert ( (string)text.ToString() == (string)userText.ToString() );
        }
        

        Deja View - the feeling that you've seen this post before.

        D R 2 Replies Last reply
        0
        • W WillemM

          The actual code is a bit different, but the essence was that the developer who wrote it screwed up big time. Converting string to string is a bit useless in my humble opinion ;P

          void SaveUserText(string userText) {
              string text = userText.ToString();
          }
          

          WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

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

          There was some SQL I had to maintain a few years back where the original programmer had done something like ToChar(ToChar(datevalue)) (I forget the exact syntax, it was RDB) several times. The guy who'd been maintaining said things like: "It's always been like that.", "It ain't broke.", and "He said it wouldn't work otherwise." I darn well fixed it anyway. With that and some other changes the program ran in ten minutes instead of forty.

          S 1 Reply Last reply
          0
          • P Pete OHanlon

            Surely that would be

            void SaveUserText(string userText)
            {    
                string text = userText.ToString();
                assert ( (string)text.ToString() == (string)userText.ToString() );
            }
            

            Deja View - the feeling that you've seen this post before.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Oh, but of course! :doh:

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            1 Reply Last reply
            0
            • P Pete OHanlon

              Surely that would be

              void SaveUserText(string userText)
              {    
                  string text = userText.ToString();
                  assert ( (string)text.ToString() == (string)userText.ToString() );
              }
              

              Deja View - the feeling that you've seen this post before.

              R Offline
              R Offline
              Russell
              wrote on last edited by
              #6

              I tryed it ....it crashes....why?;P


              Russell

              1 Reply Last reply
              0
              • P PIEBALDconsult

                There was some SQL I had to maintain a few years back where the original programmer had done something like ToChar(ToChar(datevalue)) (I forget the exact syntax, it was RDB) several times. The guy who'd been maintaining said things like: "It's always been like that.", "It ain't broke.", and "He said it wouldn't work otherwise." I darn well fixed it anyway. With that and some other changes the program ran in ten minutes instead of forty.

                S Offline
                S Offline
                StevenWalsh
                wrote on last edited by
                #7

                He said "It ain't broke" not "It aint slow"

                W 1 Reply Last reply
                0
                • S StevenWalsh

                  He said "It ain't broke" not "It aint slow"

                  W Offline
                  W Offline
                  WillemM
                  wrote on last edited by
                  #8

                  Hahaha, FxCop thought otherwise. ;P

                  WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

                  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