Skip to content

Instantly share code, notes, and snippets.

@shawnwildermuth
Created March 20, 2021 06:28
Show Gist options
  • Save shawnwildermuth/edc7112fe1a01931a68dc125c1d6f6fa to your computer and use it in GitHub Desktop.
Save shawnwildermuth/edc7112fe1a01931a68dc125c1d6f6fa to your computer and use it in GitHub Desktop.
Tuples in C# Code
using System;
namespace TroubleWithTuples
{
public class Animal
{
public (string Name, int Age) GetInfo()
{
// return name and age
return ("Max", 16);
}
}
}
using System;
namespace TroubleWithTuples
{
class Program
{
static void Main(string[] args)
{
var a = new Animal();
(string name, int age) = a.GetInfo();
Console.WriteLine($"Name: {name} Age: {age}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment