Create Tuple Array - CSharp Language Basics

CSharp examples for Language Basics:Tuple

Description

Create Tuple Array

Demo Code

using System;//from w ww  . j av a  2s  .c o m
using System.Linq;
class RegularComparisons
{
   static void Main()
   {
      var points = new[]
      {
         (1, 2), (10, 3), (-1, 5), (2, 1),(10, 3), (2, 1), (1, 1)
      };
      var distinctPoints = points.Distinct();
      Console.WriteLine($"{distinctPoints.Count()} distinct points");
      Console.WriteLine("Points in order:");
      foreach (var point in distinctPoints.OrderBy(p => p))
      {
         Console.WriteLine(point);
      }
   }
}

Result


Related Tutorials