Reputation: 159
How can I convert or cast Generic.IList
?
Encounter this error
Error CS0266 Cannot implicitly convert type 'System.Collections.Generic.IList' to 'PDM.App.DTO.Product.ProductDTO'. An explicit conversion exists (are you missing a cast?)
My Code
public async Task<ProductDTO> EditProduct(ProductDTO Product)
{
var request = new GetProducts_Activity_Request { };
var response = await GetProducts_Activity.InvokeAsync(request);
return response.Products;
}
Response class look like this
public class GetProducts_Activity_Response : BaseActivityResponse
{
public IList<ProductDTO> Products { get; set; }
}
Upvotes: 0
Views: 1831
Reputation: 3441
Change your code like this
public async Task<IList<ProductDTO>> EditProduct(ProductDTO Product)
{
var request = new GetProducts_Activity_Request { };
var response = await GetProducts_Activity.InvokeAsync(request);
return response.Products;
}
You have to change return type to Task<IList<ProductDTO>>
Upvotes: 1