G
G
getfield2021-08-12 12:09:38
.NET
getfield, 2021-08-12 12:09:38

How to return structures of different types from a method?

Complete zero in C#. I have a method that makes an asynchronous API request to a specific endpoint. The API can return both a BaseResponseModel and an ErrorModel. The method needs to be able to return Task<BaseResponseModel<SomeModel>>or Task<ErrorModel>. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-08-12
@freeExec

Or contain all your models ErrorModeland if it is not empty, then something is wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question