Re: [問題] 紀錄struct內的資料
// 前文恕刪
// 雖不是很懂原Po的需求, 不過還是隔空抓藥寫個雛形給原Po
public struct Point
{
public int X { get; set; }
public int Y { get; set; }
}
public class PropertyPoints
{
private IList<Point> _points;
public PropertyPoints(string property)
{
_points = new List<Point>();
Property = property;
}
public string Property { get; set; }
public IList<Point> Points { get { return _points; } } // 05/12修正
}
public class Data
{
private IDictionary<string, PropertyPoints> _propertyPointsMap;
public Data()
{
_propertyPointsMap = new Dictionary<string, PropertyPoints>();
}
public void Add(string property, int x, int y)
{
if (_propertyPointsMap.ContainsKey(property))
{
_propertyPointsMap[property].Points.Add(
new Point() { X = x, Y = y }
);
}
else
{
PropertyPoints propertyPoints = new PropertyPoints(property);
propertyPoints.Points.Add(new Point() { X = x, Y = y });
_propertyPointsMap.Add(property, propertyPoints);
}
}
} // 05/12修正
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.150.76
→
05/12 14:44, , 1F
05/12 14:44, 1F
※ 編輯: flamo 來自: 114.24.152.237 (05/12 20:35)
→
05/12 20:36, , 2F
05/12 20:36, 2F
※ 編輯: flamo 來自: 114.24.152.237 (05/12 20:37)
討論串 (同標題文章)
完整討論串 (本文為第 5 之 5 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章