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. do you use extension methods intensively in your projects?

do you use extension methods intensively in your projects?

Scheduled Pinned Locked Moved The Lounge
question
42 Posts 27 Posters 46 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.
  • M Midi_Mick

    Very much so! Done properly, they make the code so much more compact and readable.

    Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

    O Offline
    O Offline
    obermd
    wrote on last edited by
    #41

    Not only does proper use of extension methods do this it also "cleans" up the API. For instance, Visual Basic has a StrReverse(string) method, but the underlying dotNet framework's Reverse() extension method for System.String doesn't return a string. It returns an array of characters. I'll add extension methods for this type of situation.

    1 Reply Last reply
    0
    • S Southmountain

      just curious. recently I start to use extension methods in my projects.

      diligent hands rule....

      M Offline
      M Offline
      mbb01
      wrote on last edited by
      #42

      I use extension methods somewhat. I'm slowly building a suite of useful methods. There is also the site extensionmethod.net too. I keep the extension methods in a core library, but the methods are declared in the namespace of the class I'm targeting. That way, when I reference the core library all the extension methods are available without superfluous using statements. Be careful, there is an ongoing debate on the internets about whether they're a good thing or bad thing. I would say, use sparingly, and note that an extension method is probably sign-posting a limitation in your design. As well as other suggestions, I've used them to clean up a messy code base I've inherited. In this code base there were a number of inappropriate methods attached to a static globals class. Side-stepping the whole issue of a statics globals class, the methods attached to it were moved onto extension methods. Not a perfect solution, but migrating to extension methods helped me nudge the legacy code in the right direction.

      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