Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
C#7 tuple & async

Old format:

private async Task<Tuple<SomeArray[], AnotherArray[], decimal>>         
GetInvoiceDetailAsync(InvoiceHead invoiceHead) { ... }

How can you do that in C#7 with new tuples format?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Step 1: add the ValueTuple nuget package to your project.

Step 2: as Lucas says in his comment, change the syntax to:

private async Task<(SomeArray[], AnotherArray[], decimal)>GetInvoiceDetailAsync(
    InvoiceHead invoiceHead) 
{ 
    ...
    return (x, y, z); 
}

Note though that you can also then add names to those tuple items, along the lines of:

private async Task<(SomeArray[] x, AnotherArray[] y, decimal z)>GetInvoiceDetailAsync(
    InvoiceHead invoiceHead) 
{ 
    ... 
    return (x, y, z); 
}

And you can then access them as those names, rather than Item1, Item2 and Item3.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!