C
C#3y ago
nobody

Named tuple on delegate return type [Answered]

I've defined a delegate like this:
public delegate Task<Tuple<TEntity, bool>> AddUpdateCallbackDelegate(TEntity entity, IEnumerable<TEntity> dataSource);
public AddUpdateCallbackDelegate OnAddCallback { get; set; }

...
public async Task Test()
{
var res = await OnAddCallback(...);
res.Item1...
res.Item2...
}
public delegate Task<Tuple<TEntity, bool>> AddUpdateCallbackDelegate(TEntity entity, IEnumerable<TEntity> dataSource);
public AddUpdateCallbackDelegate OnAddCallback { get; set; }

...
public async Task Test()
{
var res = await OnAddCallback(...);
res.Item1...
res.Item2...
}
the return type etc. works just fine, but I want to name the tuple parameters instead of the default Item1/2. How could I do that?
4 Replies
nobody
nobodyOP3y ago
Thanks lul, sometimes it can be that easy
333fred
333fred3y ago
Tuple types - C# reference
Learn about C# tuples: lightweight data structures that you can use to group loosely related data elements
Angius
Angius3y ago
Or use a record when
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server