我有一個程序,我在其中添加對象到字典。字典是用int和我自定義的'Ship'類設置的。問題是我需要通過班級中的變量來組織船隻。基於類元素組織字典
船類 -
public class Ship
{
public string Name { get; set; }
public int Attack { get; set; }
public int Engine { get; set; }
public int Shield { get; set; }
public string Team { get; set; }
public string ShipClass { get; set; }
public Ship(string name, int attack, int engine, int shield, string team, string shipClass)
{
Name = name;
Attack = attack;
Engine = engine;
Shield = shield;
Team = team;
ShipClass = shipClass;
}
}
我需要通過ShipList [I] .Engine其中i下降至每艘船我要組織
Dictionary<int,Ship> ShipList = new Dictionary<int,Ship>();
。 任何幫助將是偉大的。
謝謝,這正是我一直在尋找。 – GiantDwarf