C# Extension method doesn't fit in this scenerio?
-
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
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)
-
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
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)
-
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)
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