作者flamo (迅雷不及掩耳盗铃)
看板C_Sharp
标题Re: [问题] 纪录struct内的资料
时间Tue May 11 11:16:57 2010
// 前文恕删
// 虽不是很懂原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
1F:→ conanist:可能你要打个注解 不然原po会看不懂 05/12 14:44
※ 编辑: flamo 来自: 114.24.152.237 (05/12 20:35)
2F:→ flamo:修正bug 05/12 20:36
※ 编辑: flamo 来自: 114.24.152.237 (05/12 20:37)