coding style - proper way to create Overload methods in api C# -


this question in regards proper , acceptable coding practice given following scenario.

i have following 2 methods.

public tservice getduplexclientchannel<t>(bindingtype bindingtype, endpointaddress endpointaddress) t : tservice {       .. work .. ..       return instanceof(tservice); }  public tservice getduplexclientchannel<t>(bindingtype bindingtype, string endpointaddress) t : tservice { // call above method , return it. return getduplexclientchannel<t>(bindingtype, new endpointaddress(endpointaddress); 

}

in first example have method work, , method b overload of a, calls work.

i know if acceptable pattern , or should code repeated in second method? best practice this.

i have looked @ link not answer question proper or not proper: better way overload methods in c#

yes, absolutely acceptable pattern since in case, generic argument seems unrelated type of endpoint address.

it seen in variety of libraries , frameworks such .net framework (console.write) or following dapper source:

public static task<ienumerable<object>> queryasync(this idbconnection cnn,      type type, commanddefinition command) {     return queryasync<object>(cnn, type, command); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -