I am getting an exception.
Cannot implicitly convert type
'System.Collections.Generic.List<IntegraPay.Domain.SObjects.Industry>'
to'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<IntegraPay.Domain.SObjects.Industry>>'
Below is my property and method.
private List<WebFormFieldContent> WebFormFields { get; set; } =
new List<WebFormFieldContent>();
Task<IEnumerable<WebFormFieldContent>> IRegistrationRepository.GetWebFormFields()
{
return WebFormFields;
}
This error typically happens when you are missing async
in the method declaration.
When you put async
in the signature, C# compiler adds "magic" to do the conversion from an object to a Task<T>
returning that object.
However, in your situation async
is unnecessary, because you return a task with a result that you already have:
return Task.FromResult<IEnumerable<WebFormFieldContent>>(
WebFormFields
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With