How to consolidate similar methods to one

  • Thread starter Thread starter Raj
  • Start date Start date
R

Raj

Hi All,
I have a method call GetStationListenUrl that exists as three
overloaded methods

1) public static string GetUrl( int strength, string
strengthNavigateUrl, zzz.StreamRow[] sra, string bandName)

2) public static string GetUrl( int strength, string
strengthNavigateUrl, xxx.StreamsRow[] sra, string bandName)

3) public static string GetUrl( int strength, string
strengthNavigateUrl, yyy.StreamsRow[] sra, string bandName)

zzz, xxx, yyy have common fields that the above method will access.
How would I consolidate all these three methods to one GetUrl.

TIA
Raj
 
Hi Raj,

I take it zzz, xxx and yyy are all separate classes, and therefore you need
to provide the overloaded methods to accommodate each class? Also, I'm
assuming that the first GetUrl you listed actually
 
Ooops! Pressed some random keyboard combo that actually sent the mail before
I had finished!

As I was saying....


Raj said:
zzz, xxx, yyy have common fields that the above method will access.
How would I consolidate all these three methods to one GetUrl.

I take it zzz, xxx and yyy all have an inner class/struct called StreamsRow,
or StreamRow (assuming there is a typo in the first GetUrl method?)? You
could get rid of the overloading by having one class called StreamRow which
is used by xxx,yyy and zzz classes, rather than having three separate inner
classes. If this isn't possible, then have all the inner classes implement a
common interface, being the collection of functions needed by the GetUrl
method.

Not sure if I missed something here!?

Tobes
 
Back
Top