Reputation: 434
I'm trying to code a function, what calles a function from a class what is derived from an interface (ISFAction).
Where is the difference/what is better?
public string Create<T>(ISFServer server, T action, string[] args) where T : ISFAction
{
string requestUrl = null;
string actionPart = action.GenerateAction(args);
requestUrl += server.serverUri.ToString();
requestUrl += "request.php?req=";
requestUrl += actionPart;
return requestUrl;
}
And my other version:
public string Create(ISFServer server, ISFAction action, string[] args)
{
string requestUrl = null;
string actionPart = action.GenerateAction(args);
requestUrl += server.serverUri.ToString();
requestUrl += "request.php?req=";
requestUrl += actionPart;
return requestUrl;
}
What is better?
Upvotes: 0
Views: 329
Reputation: 172616
The second code snippet (without the generic type argument) is better, because (as you showed in the first code snippet) the generic type argument is useless; it isn't used at all. This just complicates code without a reason.
Upvotes: 2