The purpose is to create a valueTuple dynamically from a collection. In this collection, values might be different Type. The created ValueTuple would have the same value type.
IList<object> tupleElements = new List<object>();
tupleElements.Add(16);
tupleElements.Add("any string");
var vt1 = ValueTuple.Create(tupleElements[0], tupleElements[1]);
var vt2 = ValueTuple.Create(16, "any string");
From the debug information, the two valueTuples contain the same values. But, the type is different. vt1 is object,object. vt2 is int, string.
How to make vt1 is (int, string) type too?
I can't use the way to create vt2 because the elements type in collection is different each time. Next step, the element in list might be 1, "any string", 2, 3, "other string". At this moment, the ValueTuple would be (int, string, int, int, string) instead of (object,object,object, object, object).
Any suggestion is welcome! Thanks!