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. Facepalm of the day.

Facepalm of the day.

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasecomquestion
24 Posts 11 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.
  • J Jorgen Andersson

    So I was building an application that presents a list of files matched with info in a database. Everything was working fine and dandy but horrendously slow. I quickly found the culprit to be in this function:

    Func GetIDPart_Of_FileName = FileName => Convert.ToInt32(FileName.Substring(FileName.IndexOf('_') + 1, FileName.IndexOf('.') - FileName.IndexOf('_')));

    The files are built in the form of ID_AnotherID.Extension and what I wanted was AnotherID Can anyone see what I did wrong? :) Do note that it was giving correct results. fixed typo

    Wrong is evil and must be defeated. - Jeff Ello[^]

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #21

    Well, a little late to the party, but this is why I have a whole bunch of string extensions, like this "Between" and "ToInt32": FileName.Between('_', '.').ToInt32() And then you would never have included the '.' by accident. ;) Marc

    Imperative to Functional Programming Succinctly Higher Order Programming

    J G 2 Replies Last reply
    0
    • M Marc Clifton

      Well, a little late to the party, but this is why I have a whole bunch of string extensions, like this "Between" and "ToInt32": FileName.Between('_', '.').ToInt32() And then you would never have included the '.' by accident. ;) Marc

      Imperative to Functional Programming Succinctly Higher Order Programming

      J Offline
      J Offline
      Jorgen Andersson
      wrote on last edited by
      #22

      Just put that on my todo list. :thumbsup:

      Wrong is evil and must be defeated. - Jeff Ello[^]

      M 1 Reply Last reply
      0
      • J Jorgen Andersson

        Just put that on my todo list. :thumbsup:

        Wrong is evil and must be defeated. - Jeff Ello[^]

        M Offline
        M Offline
        Marc Clifton
        wrote on last edited by
        #23

        Send me a direct email and I'll send you the .cs file of my extensions. There's this[^] too. Marc

        Imperative to Functional Programming Succinctly Higher Order Programming

        1 Reply Last reply
        0
        • M Marc Clifton

          Well, a little late to the party, but this is why I have a whole bunch of string extensions, like this "Between" and "ToInt32": FileName.Between('_', '.').ToInt32() And then you would never have included the '.' by accident. ;) Marc

          Imperative to Functional Programming Succinctly Higher Order Programming

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #24

          very cool (aka :cool: ) 'g'

          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