7,774
社区成员




private List<RectangleEx> CRectLst = new List<RectangleEx>();
private List<Rectangle> RectLst = new List<Rectangle>();
public class RectangleEx
{
private Rectangle rect;
public Rectangle Rect
{
get
{
return this.rect;
}
set
{
this.rect = value;
}
}
public int X
{
get
{
return this.rect.X;
}
set
{
this.rect.X = value;
}
}
public int Y
{
get
{
return this.rect.Y;
}
set
{
this.rect.Y = value;
}
}
public int Width
{
get
{
return this.rect.Width;
}
set
{
this.rect.Width = value;
}
}
public int Height
{
get
{
return this.rect.Height;
}
set
{
this.rect.Height = value;
}
}
public int Left
{
get
{
return this.rect.Left;
}
}
public int Right
{
get
{
return this.rect.Right;
}
}
public int Top
{
get
{
return this.rect.Top;
}
}
public int Bottom
{
get
{
return this.rect.Bottom;
}
}
public Point Location
{
get
{
return this.rect.Location;
}
set
{
this.rect.Location = value;
}
}
public RectangleEx(int x, int y, int width, int height)
{
this.rect = new Rectangle(x, y, width, height);
}
public bool Contains(int x, int y)
{
return this.rect.Contains(x, y);
}
public void Offset(int x, int y)
{
this.rect.Offset(x, y);
}
}
this.rect0 = new RectangleEx(50, 50, 40, 50);
this.RectLst.Add(this.rect0.Rect);
this.RectLst[0].X = 100; //报错,错误1
this.CRectLst.Add(this.rect0);
this.CRectLst[0].X = 1000;//未报错。