Created
October 23, 2016 10:22
-
-
Save controlflow/b30bc04ecd96ccf77cc227f0367da7ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
using System.Collections.Generic; | |
public static class C { | |
public static void M() { | |
var xs = new Dictionary<int, string>(); | |
foreach ((int id, string key) in xs) { | |
// ... | |
// int a = 0, b = 1; | |
// ... | |
// GC.KeepAlive((b, a) = (1, 2)); | |
} | |
foreach (var (id, key) in xs) { | |
// ... | |
// id++; | |
} | |
} | |
public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> kv, out T1 item1, out T2 item2) { | |
item1 = kv.Key; | |
item2 = kv.Value; | |
} | |
} | |
namespace System { | |
public struct ValueTuple<T1, T2> { | |
public T1 Item1; | |
public T2 Item2; | |
public ValueTuple(T1 item1, T2 item2) : this() { } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment