标题:c#参数 这里是怎么传递的?
只看楼主
aamen110
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-8-14
结帖率:50%
已结贴  问题点数:10 回复次数:5 
c#参数 这里是怎么传递的?
public partial class Form1 : Form
    {
      
        public Form1()
        {
            InitializeComponent();
        }

      

        private void button3_Click(object sender, EventArgs e)
        {
            shape line = new line(10, 10, 100, 100);
            line.draw(this.panel1.CreateGraphics());
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            shape ep = new eillpse(20, 20, 200, 200);
            ep.draw(this.panel1.CreateGraphics());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            shape re = new eillpse(20, 20, 200, 200);
            re.draw(this.panel1.CreateGraphics());
        }
    }

   public  class line :shape
   {
       public line(int x1, int y1, int x2, int y2)
           : base(x1, y1, x2, y2)
       { }
       public override void draw(Graphics g)
       {
         
          Pen mypen =new Pen (Color .Red )   ;
          g.DrawLine(mypen , this.X1  , this.Y1, this.X2, this.Y2);
       }
        
    }
 public class eillpse : shape
    {
        public eillpse(int x1, int y1, int x2, int y2)
            : base(x1, y1, x2, y2)
        { }
        public override void draw(Graphics g)
        {

            Pen mypen = new Pen(Color.Red);
            g.DrawEllipse(mypen, this.X1, this.Y1, this.X2, this.Y2);
        }

    }
 public class regricle : shape
    {
        public regricle(int x1, int y1, int x2, int y2)
            : base(x1, y1, x2, y2)
        { }
        public override void draw(Graphics g)
        {

            Pen mypen = new Pen(Color.Red);
            g.DrawRectangle(mypen, this.X1, this.Y1, this.X2, this.Y2);
        }

    }
搜索更多相关主题的帖子: private public class 
2011-10-21 23:14
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
得分:3 
继承?

   唯实惟新 至诚致志
2011-10-22 13:56
zzqqrr
Rank: 6Rank: 6
来 自:299294817
等 级:侠之大者
威 望:1
帖 子:155
专家分:408
注 册:2011-6-11
得分:3 
呵,还太会

59izk,com神奇百货,神奇百货网官网,shenqi,一个神奇的导购站!!
2011-10-22 13:56
风雨如晦
Rank: 1
来 自:哈尔滨
等 级:新手上路
帖 子:3
专家分:4
注 册:2009-8-26
得分:3 
哈哈看的不算太明白.

通往成功的路.总是在施工中.................
2011-10-22 14:12
lovesun3
Rank: 2
等 级:论坛游民
帖 子:6
专家分:32
注 册:2011-10-25
得分:3 
line,eillpse ,regricle三个类  都继承了shape类 对shape类的draw函数进行重写
 public eillpse(int x1, int y1, int x2, int y2)
            : base(x1, y1, x2, y2)
        { }
这段是 继承自shape的构造函数。。传入的参数就是传给了 x1,y1,x2,y2
2011-10-26 00:17
lovesun3
Rank: 2
等 级:论坛游民
帖 子:6
专家分:32
注 册:2011-10-25
得分:0 
http://msdn.(VS.80).aspx
2011-10-26 00:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-353134-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047909 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved