using System.Collections.Generic;
public static void Main()
var colors = new ColorItem[3];
colors[0] = new ColorItem("C1", "#ededed");
colors[1] = new ColorItem("C2", "#fff");
colors[2] = new ColorItem("C3", "#000");
var sample = new ColorProperties();
Transpose(colors, sample, c => c.Label, c=> c.Value);
Console.WriteLine(sample.C1);
Console.WriteLine(sample.C2);
Console.WriteLine(sample.C3);
public static void Transpose<T>(IEnumerable<T> sourceSet, object target, Func<T,string> getName, Func<T, string> getValue)
var properties = target.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
foreach (var propertyInfo in properties)
var color = sourceSet.FirstOrDefault(f => propertyInfo.Name == getName(f));
propertyInfo.SetValue(target, getValue(color));
public ColorItem(string label, string value) { Label = label; Value = value; }
public string Label { get; set; }
public string Value { get; set; }
public class ColorProperties
public string C1 { get; set; }
public string C2 { get; set; }
public string C3 { get; set; }