CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<KeyValues> values = new List<KeyValues>()
{new KeyValues()
{Key = "SystemId", Value = "12"}, new KeyValues()
{Key = "SystemName", Value = "LTPVBN21"}, new KeyValues()
{Key = "Location", Value = "NJ2"}};
SystemInformation information = new SystemInformation();
foreach(var item in values)
{
information.GetType()
.GetProperty(item.Key)
.SetValue(information, item.Value);
}
Console.WriteLine(information.SystemId);
Console.WriteLine(information.SystemName);
Console.WriteLine(information.Location);
}
}
public class KeyValues
{
public string Key
{
get;
set;
}
public string Value
{
get;
set;
}
}
public class SystemInformation
{
public string SystemId { get; set; }
public string SystemName { get; set; }
public string Location { get; set; }
}