ソースコード
using System.Collections.Generic; public static class KeyValuePairExt { public static void Deconstruct<TKey, TValue> ( this KeyValuePair<TKey, TValue> self, out TKey key, out TValue value ) { key = self.Key; value = self.Value; } }
使用例
通常
foreach ( var elem in m_table ) { Debug.Log( elem.Key + ": " + elem.Value ); }
Deconstruction
foreach ( var ( key, value ) in m_table ) { Debug.Log( key + ": " + value ); }