Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static TO ConvertValue<TI, TO>(TI value) => (TO)Convert.ChangeType(value, typeof(TO));
- public static void Deconstruct<TI, TO>(this IEnumerable<TI> src, out TO p1, out TO p2) {
- var e = src.GetEnumerator();
- p1 = e.MoveNext() ? ConvertValue<TI,TO>(e.Current) : default(TO);
- p2 = e.MoveNext() ? ConvertValue<TI,TO>(e.Current) : default(TO);
- }
- (int p1, int p2) = new int[] { 1, 2, 3, 4 };
- Ext.Deconstruct(new int[] { 1, 2, 3 }, out p1, out p2);
Add Comment
Please, Sign In to add comment