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. General Programming
  3. C#
  4. C# Extension method doesn't fit in this scenerio?

C# Extension method doesn't fit in this scenerio?

Scheduled Pinned Locked Moved C#
csharpvisual-studiowpfdata-structuresquestion
23 Posts 6 Posters 1 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.
  • S Scott Dorman

    I'd highly reccommend against doing that. It can and most likely will lead to a lot of maintenance headaches later. It will also make it harder for new developers to get up to speed on the codebase since there is now a "new" Array class that isn't the standard one that everyone is familiar with.

    Scott Dorman

    Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


    Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

    M Offline
    M Offline
    Michael Sync
    wrote on last edited by
    #21

    Thanks, Scott. It's true that it will lead a lot of maintenance headaches but the problem is that we already have a lot of classes written for WPF project. I'm trying to port them to Silverlight-compatible project. What I was thinking is that if we can use the same way that we used to use for WPF then new developer won't need to remember that we have to use this (e.g ArrayHelper.Find) in Silverlight and we have to use that (ie. Array.Find) in WPF. All he need to do is that just use Array.Find no matter whether he is in Silverlight or WPF..

    Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

    S 1 Reply Last reply
    0
    • D DaveyM69

      Michael Sync wrote:

      But I will need to change Array.Remove to System.Array.Remove

      No. For any methods that you need to keep that exist in System.Array - simply create a method in your class with the same return type, name and signature. Then in your method return the System.Array's method result passing the parameters to it.

      Michael Sync wrote:

      Another thing: I think the name will be conflict.

      No, the IDE and compiler will assume yournamespace.class if there is also a System.class with the same class name.

      Dave

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #22

      Thanks, Dave. I will try. But Scott's suggestion is also nice one. I will keep the suggestions from both of you and I will mentioned about that to my manager..

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

      1 Reply Last reply
      0
      • M Michael Sync

        Thanks, Scott. It's true that it will lead a lot of maintenance headaches but the problem is that we already have a lot of classes written for WPF project. I'm trying to port them to Silverlight-compatible project. What I was thinking is that if we can use the same way that we used to use for WPF then new developer won't need to remember that we have to use this (e.g ArrayHelper.Find) in Silverlight and we have to use that (ie. Array.Find) in WPF. All he need to do is that just use Array.Find no matter whether he is in Silverlight or WPF..

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

        S Offline
        S Offline
        Scott Dorman
        wrote on last edited by
        #23

        I understand the problem you are looking at. It's a trade off as either way you are going to end up with possible maintenance issues later.

        Scott Dorman

        Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


        Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

        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