为什么要把它们存放到数据库里去呢?point是支持ISerializable那样不是更方面吗?

解决方案 »

  1.   

    给段代码你:using System;
    using System.Drawing;
    using System.Runtime.Serialization;namespace MyCSharp
    {
      public interface IShape 
      {
        void Draw(Graphics g);
      }  [Serializable]
      public class Line : IShape
      {
        Point startPoint, endPoint;
        public Line(Point startPoint, Point endPoint) 
        {
          this.startPoint = startPoint;
          this.endPoint = endPoint;
        }
        public void Draw(Graphics g) 
        {
          g.DrawLine(Pens.Black, startPoint, endPoint);
        }
      }  [Serializable]
      public class Rect : IShape
      {
        Rectangle rect;
        public Rect(Rectangle rect) 
        {
          this.rect = rect;
        }
        public void Draw(Graphics g)
        {
          g.DrawRectangle(Pens.Black, rect);
        }
      }  [Serializable]
      public class Ellipse : IShape
      {
        Rectangle rect;
        public Ellipse(Rectangle rect)
        {
          this.rect = rect;
        }
        public void Draw(Graphics g)
        {
          g.DrawEllipse(Pens.Black, rect);
        }
      }}