How to assign multiple values to multiple variables in one line with C#

1 Answer

0 votes
using System;
					
public class Program
{
	public static void Main()
	{
		var (a, b, c, d) = (42, "c#", 3.14, 890000);
		
		Console.WriteLine(a);
		Console.WriteLine(b);
		Console.WriteLine(c);
		Console.WriteLine(d);
	}
}


/*
run:

42
c#
3.14
890000

*/

 



answered Jul 14, 2025 by avibootz
...