There will be a public interface shared by both ValueTuple and Tuple types, called ITuple. It is not completely finalized and it is not implemented yet, but you can see more details on the proposed implementation at https://github.com/dotnet/corefx/pull/10068

This interface is intended for future pattern-matching scenarios.

By “multiple keys”, do you really mean, “compound keys”? I can see how it would work with compound keys, but I can’t see how it would work for indexing on different keys within the tuple, as dictionaries only index off of 1 object.

]]>Currently:

public void Foo()

{

var places = new[] { new Point(1, 3), new Point(2, 4), new Point(-1, -1)};

var placesByDistance = places.OrderBy(p => p, new DistanceComparer());

}

class DistanceComparer : IComparer

{

public int Compare(Point x, Point y)

{

return (Math.Pow(x.X, 2) + Math.Pow(x.Y, 2))

.CompareTo(Math.Pow(y.X, 2) + Math.Pow(y.Y, 2));

}

}

Better:

public void Foo()

{

var places = new[] { new Point(1, 3), new Point(2, 4), new Point(-1, -1)};

var placesByDistance = places.OrderBy(p => p, new IComparer {

public int Compare(Point x, Point y)

{

return (Math.Pow(x.X, 2) + Math.Pow(x.Y, 2))

.CompareTo(Math.Pow(y.X, 2) + Math.Pow(y.Y, 2));

}

});

}

Even better: Infer single-method interfaces:

public void Foo()

{

var places = new[] { new Point(1, 3), new Point(2, 4), new Point(-1, -1)};

var placesByDistance = places.OrderBy(p => p, (x, y) => (Math.Pow(x.X, 2) + Math.Pow(x.Y, 2)).CompareTo(Math.Pow(y.X, 2) + Math.Pow(y.Y, 2)));

}

This pattern is quite handy and common in Java. Read any Android app’s source code and it’s littered with in-place instances of the Runnable interface that get passed around for callback and event-handling. Would be awesome to have this in C# as well.

]]>; ; ; ; ; ; ;

tired of it. ]]>

Moreover, Try methods are similar to patterns in an “is” expression when you think about it: They return a boolean, and when successful they emit extra results “on the side”. So the two features complement each other well.

]]>