Получить имена в кортеже, вложенном в другой кортеж.C#

Место общения программистов C#
Anonymous
Получить имена в кортеже, вложенном в другой кортеж.

Сообщение Anonymous »


Как получить имена в кортеже в C# с помощью отражения, если один кортеж вложен в другой кортеж?
Например, вот так

Код: Выделить всё

public static void M(((int n1, uint n2) o1, ((int p1, (int w1, uint w2) p2, uint p3) q1, ((int x1, uint x2) r1, byte r2) q2) o2) k) {}
Through the TupleElementNamesAttribute attribute, I can get an array of all value names.

Код: Выделить всё

ParameterInfo parameterInfo;
parameterInfo.GetCustomAttribute().TransformNames;

//"o1", "o2", "n1", "n2", "q1", "q2", "p1", "p2", "p3", "w1", "w2", "r1", "r2", "x1", "x2"
But it is not clear how to associate an element of a tuple with its name in the array because there is no index.


Источник: https://stackoverflow.com/questions/781 ... ther-tuple

Вернуться в «C#»