Is there an easier way to do the following:
public static class ValueTupleAdditions { public static IEnumerable<object> ToEnumerable<A, B>(this ValueTuple<A, B> tuple) { yield return tuple.Item1; yield return tuple.Item2; } public static IEnumerable<object> ToEnumerable<A, B, C>(this ValueTuple<A, B, C> tuple) { yield return tuple.Item1; yield return tuple.Item2; yield return tuple.Item3; } [etc] }
EDITOR: Since people are asking for a use case, you are here.
using Xunit; namespace Whatever { public class SomeTestClass { public static IEnumerable<(string, Expression<Func<string, string>>, string)> RawTestData() { yield return ("Hello", str => str.Substring(3), "lo"); yield return ("World", str => str.Substring(0, 4), "worl"); } public static IEnumerable<object[]> StringTestData() { return RawTestData().Select(vt => new object[] { vt.Item1, vt.Item2, vt.Item3 });
c # ienumerable valuetuple
William Jockusch
source share