Tuple Deconstruction Assignments - CSharp Language Basics

CSharp examples for Language Basics:Tuple

Description

Tuple Deconstruction Assignments

Demo Code

using System;/*from  ww  w.ja va  2 s.co m*/
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
class TupleDeconstructionAssignments
{
   static (int x, int y, string text) MethodReturningTuple() => (1, 2, "t");
   static void Main()
   {
      int a = 20;
      int b = 30;
      string name = "before";
      Console.WriteLine($"a: {a}; b: {b}; name: {name}");
      (a, b, name) = MethodReturningTuple();
      Console.WriteLine($"a: {a}; b: {b}; name: {name}");
   }
}

Result


Related Tutorials