✅ How to return List from RestClient?
Hi, I am making rest client for my application using RestSharp (like their twitter client in guide https://restsharp.dev/usage.html#api-client).
Everywhere in code I have something like But one endpoint returns just an array of entities and I don't like how
Task<List<CoolerEntity2>>
looks
In TypeScript I could make alias type GetEntities = CoolerEntity2[]
and use it. Is there something similar in C#?
Also, should I use ICollection
instead of List
?
P.S. Models (or DTO?) and client code are in separated files4 Replies
You can alias types
using GetEntities = ICollection<GetSomethingResponse>
Whether you return List or ICollection depends on what you want the consumers to do, if you want them to access elements by index then IList or ListOh, thank you, appreciate your help! I checked c# api reference and guess even IEnumerable will be enough
<:MadoThumbsUp_MM:406514447973351444>
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.