Created
March 20, 2021 06:28
-
-
Save shawnwildermuth/edc7112fe1a01931a68dc125c1d6f6fa to your computer and use it in GitHub Desktop.
Tuples in C# Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TroubleWithTuples | |
{ | |
public class Animal | |
{ | |
public (string Name, int Age) GetInfo() | |
{ | |
// return name and age | |
return ("Max", 16); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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