using System.Collections.Generic;
private static Dictionary<string, object[]> ValuesFor = new Dictionary<string, object[]>()
{ typeof(int).ToString(), new object[] { 0, 1, 2, 3, 4, 5 } },
{ typeof(bool).ToString(), new object[] { true, false } }
public static void Main()
var properties = typeof(A).GetProperties(BindingFlags.Instance | BindingFlags.Public);
int[] valueIndices = new int[properties.Length];
createObject(properties, valueIndices);
} while (setNext(properties, valueIndices));
public static bool setNext(PropertyInfo[] properties, int[] valueIndices)
for (var i = 0; i < properties.Length; i++)
if (valueIndices[i] < ValuesFor[properties[i].PropertyType.ToString()].Length - 1) {
for (var j = 0; j < i; j++)
public static void createObject(PropertyInfo[] properties, int[] valueIndices)
for (var i = 0; i < properties.Length; i++)
properties[i].SetValue(a, ValuesFor[properties[i].PropertyType.ToString()][valueIndices[i]]);
public static void print(object a, PropertyInfo[] properties)
Console.Write("Created : ");
for (var i = 0; i < properties.Length; i++)
Console.Write(properties[i].Name + "=" + properties[i].GetValue(a) + " ");
public int value { get; set; }
public bool foo { get; set; }
public bool bar { get; set; }
public bool boo { get; set; }