應該如何理解下面的行?C# - 澄清'where T:new()'
public T Execute<t>(RestRequest request) where T : new()
它是以下代碼的一部分。
public T Execute<t>(RestRequest request) where T : new()
{
var client = new RestClient();
client.BaseUrl = BaseUrl;
request.RequestFormat = DataFormat.Json;
// Used on every request
request.AddParameter("country", "gb", ParameterType.UrlSegment);
var response = client.Execute<t>(request);
return response.Data;
}
而且還這樣一條:
公共類的RSSItems:列表{}
[對類型參數的約束](http://msdn.microsoft.com/zh-cn/library/d5x73970(v = vs80).aspx ) – zerkms 2012-04-24 11:26:35
你沒有使用這裏的約束 – 2012-04-24 11:27:43
http://msdn.microsoft.com/en-us/library/sd2w2ew5.aspx – eandersson 2012-04-24 11:27:48