Spotify API-NET Searchrequest 没有给出类型参数
Spotify API-NET Searchrequest no Type argument given
我一直在尝试使用 spotifyAPI-NET
,我只是尝试创建一个可以搜索艺术家的 SearchRequest,但我似乎无法正确分配参数。
SearchRequest searchRequest = new SearchRequest {Type = SearchRequest.Types.Artist, Query = "Ren"};
SearchRequest
构造函数需要两个必需参数,即 type
和 query
。
您目前没有向构造函数传递任何参数。
您需要更改:
new SearchRequest {Type = SearchRequest.Types.Artist, Query = "Ren"}
至:
new SearchRequest(SearchRequest.Types.Artist, "Ren")
如果您想了解更多构造函数的工作原理:Constructors (C# Programming Guide)
public SearchRequest(Types type, string query)
{
Ensure.ArgumentNotNull(type, nameof(type));
Ensure.ArgumentNotNullOrEmptyString(query, nameof(query));
Type = type;
Query = query;
}
var search = await spotify.Search.Item(new SearchRequest(
SearchRequest.Types.All, "Jake"
));
我一直在尝试使用 spotifyAPI-NET
,我只是尝试创建一个可以搜索艺术家的 SearchRequest,但我似乎无法正确分配参数。
SearchRequest searchRequest = new SearchRequest {Type = SearchRequest.Types.Artist, Query = "Ren"};
SearchRequest
构造函数需要两个必需参数,即 type
和 query
。
您目前没有向构造函数传递任何参数。
您需要更改:
new SearchRequest {Type = SearchRequest.Types.Artist, Query = "Ren"}
至:
new SearchRequest(SearchRequest.Types.Artist, "Ren")
如果您想了解更多构造函数的工作原理:Constructors (C# Programming Guide)
public SearchRequest(Types type, string query)
{
Ensure.ArgumentNotNull(type, nameof(type));
Ensure.ArgumentNotNullOrEmptyString(query, nameof(query));
Type = type;
Query = query;
}
var search = await spotify.Search.Item(new SearchRequest(
SearchRequest.Types.All, "Jake"
));