-
-
Save fatihdgn/f8fd1077aaf6ab7fa12c3a92b68e9f85 to your computer and use it in GitHub Desktop.
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
public static class TupleExtensions | |
{ | |
public static Point ToPoint(this (int x, int y) self) => new Point(x,y); | |
public static (int x, int y) => ToTuple(this Point self) => (self.X, self.Y); | |
} | |
// First, let's create a new point. | |
var p = new Point(10,20); | |
// And deconstruct it with converting it a tuple first with ToTuple extension method. | |
var (x,y) = p.ToTuple(); | |
// At last, create a tuple using x and y variables and convert it to a point using ToPoint extension method. | |
var p2 = (x,y).ToPoint(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment