Skip to content

Instantly share code, notes, and snippets.

@neiesc
Last active June 19, 2021 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neiesc/757da62a6e9c143252414ae3c887bb9b to your computer and use it in GitHub Desktop.
Save neiesc/757da62a6e9c143252414ae3c887bb9b to your computer and use it in GitHub Desktop.
dotnet Hands-On: Como criar tuplas e usar desconstrutor, descartes e operadores nelas em C#
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
(string, int) populacao = ("Rio Preto", 500_000);
Console.WriteLine($"{populacao.Item1}: {populacao.Item2}");
//var populacao = ("Rio Preto", 500_000);
//Console.WriteLine($"{populacao.Item1}: {populacao.Item2}");
//(string cidade, int populacao) populacao = ("Rio Preto", 500_000);
//Console.WriteLine($"{populacao.cidade}: {populacao.populacao}");
//var populacao = ("Rio Preto", 500_000);
//Console.WriteLine(populacao);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
//(string cidade, int populacao) = ObtetrPopulacaoDaCidade();
//Console.Write($"{cidade}: {populacao}");
//var (cidade, populacao) = ObtetrPopulacaoDaCidade();
//Console.Write($"{cidade}: {populacao}");
//(string cidade, var populacao) = ObtetrPopulacaoDaCidade();
//Console.Write($"{cidade}: {populacao}");
string cidade;
int populacao;
(cidade, populacao) = ObtetrPopulacaoDaCidade();
Console.Write($"{cidade}: {populacao}");
}
private static (string cidade, int populacao) ObtetrPopulacaoDaCidade()
{
return ("Rio Preto", 500_000);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var (_, populacao) = ObtetrPopulacaoDaCidade();
Console.Write(populacao);
}
private static (string cidade, int populacao) ObtetrPopulacaoDaCidade()
{
return ("Rio Preto", 500_000);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
Console.WriteLine((1, 1) == (1, 1));
Console.WriteLine((1, 2) == (1, 1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment