using System.Collections.Generic;
using System.Diagnostics;
static Dictionary<string, FieldInfo[]> field = new Dictionary<string, FieldInfo[]>();
var type = this.GetType();
if(!field.ContainsKey(type.Name))
field[type.Name] = type.GetFields();
public FieldInfo[] GetField()
public class SOSDan : Club
public int mikuruCostumeCount;
public int boardGameCount;
public class ComputerResearch : Club
public int computerCount;
public int keyboardCount;
public static void Main()
var sosDan = new SOSDan() { mikuruCostumeCount = 3, boardGameCount = 2 };
var computerReserch = new ComputerResearch() { computerCount = 6, keyboardCount = 12 };
Club[] clubList = new Club[]{ sosDan, computerReserch };
Stopwatch sw = new Stopwatch();
for(int i=0; i<1000; ++i){
var seitokai_type2 = new InventoryControl_Type2();
foreach(var club in clubList)
seitokai_type2.InventoryControl(club);
Console.Write(sw.Elapsed);
public class InventoryControl_Type2
public Dictionary<string, object> parameters = new Dictionary<string, object>();
public void InventoryControl(Club club)
var type = club.GetType().Name;
public void CollectVariables(Club club)
foreach(var field in club.GetField())
parameters[field.Name] = field.GetValue(club);
public void AdminOrderForSOS()
var mikuruCostumeCount = (int) parameters["mikuruCostumeCount"];
Console.Write("SOS단은 개인 복장 " + mikuruCostumeCount +"벌을 집에 보관하세요\n\n");
public void InventoryControl(string name, Dictionary<string, object> param)
foreach(var key in param.Keys)
parameters[key] = param[key];
public void AdminOrderForCR()
var keyboardCount = (int) parameters["keyboardCount"];
Console.Write("컴퓨터연구회는 키보드 " + keyboardCount +"개 중에 안 쓰는거 학교에 반납하세요\n\n");