c#错误1:找不到类型或命名空间名称“ArrayList”(是否缺少 using 指令或程序集引用?) 5
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace GraphicsDraw
{
public partial class Form1 : Form
{
ArrayList points;
Point currentPoint;
Pen thepen;
float penwidth;
SolidBrush thebrush;
private System.Windows.Forms.Button btnColor;
private System.Windows.Forms.ListBox lstPenStyle;
private System.Windows.Forms.CheckBox rbPen;
Color thecolor;
public Form1()
{
InitializeComponent();
currentPoint = new Point(50,10);
points = new ArrayList();
points.Add(currentPoint);
penwidth = 1;
thecolor = Color.Black;
thepen = new Pen(thecolor);
thebrush = new SolidBrush(thecolor);
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (currentPoint.X != e.X || currentPoint.Y != e.Y)
{
currentPoint.X = e.X;
currentPoint.Y = e.Y;
points.Add(currentPoint);
this.Invalidate();
this.Update();
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] ps=(Point[]) points.ToArray(typeof(Point));
if (rbLine.Checked)
g.DrawLine(Pens.Black, ps[0], ps[ps.Length - 1]);
else if (rbRectangle.Checked)
g.DrawRectangle(thepen, ps[0].X, ps[0].Y, ps[ps.Length - 1].X - ps[0].X, ps[ps.Length - 1].Y - ps[ps.Length - 1].Y);
else if (rbCurve.Checked)
g.DrawCurve(thepen, ps);
else if (rbPolygon.Checked)
g.DrawPolygon(thepen, ps);
else if (rbEllipse.Checked)
g.DrawEllipse(thepen,ps[0].X,ps[0].Y,ps[ps.Length-1].X-ps[0].X,ps[ps.Length-1].Y-ps[0].Y);
}
private void ChangeDrawType(object sender, PaintEventArgs e)
{
points.Clear();
currentPoint = new Point(50,10);
points.Add(currentPoint);
}
}
} 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace GraphicsDraw
{
public partial class Form1 : Form
{
ArrayList points;
Point currentPoint;
Pen thepen;
float penwidth;
SolidBrush thebrush;
private System.Windows.Forms.Button btnColor;
private System.Windows.Forms.ListBox lstPenStyle;
private System.Windows.Forms.CheckBox rbPen;
Color thecolor;
public Form1()
{
InitializeComponent();
currentPoint = new Point(50,10);
points = new ArrayList();
points.Add(currentPoint);
penwidth = 1;
thecolor = Color.Black;
thepen = new Pen(thecolor);
thebrush = new SolidBrush(thecolor);
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (currentPoint.X != e.X || currentPoint.Y != e.Y)
{
currentPoint.X = e.X;
currentPoint.Y = e.Y;
points.Add(currentPoint);
this.Invalidate();
this.Update();
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] ps=(Point[]) points.ToArray(typeof(Point));
if (rbLine.Checked)
g.DrawLine(Pens.Black, ps[0], ps[ps.Length - 1]);
else if (rbRectangle.Checked)
g.DrawRectangle(thepen, ps[0].X, ps[0].Y, ps[ps.Length - 1].X - ps[0].X, ps[ps.Length - 1].Y - ps[ps.Length - 1].Y);
else if (rbCurve.Checked)
g.DrawCurve(thepen, ps);
else if (rbPolygon.Checked)
g.DrawPolygon(thepen, ps);
else if (rbEllipse.Checked)
g.DrawEllipse(thepen,ps[0].X,ps[0].Y,ps[ps.Length-1].X-ps[0].X,ps[ps.Length-1].Y-ps[0].Y);
}
private void ChangeDrawType(object sender, PaintEventArgs e)
{
points.Clear();
currentPoint = new Point(50,10);
points.Add(currentPoint);
}
}
} 展开
2个回答
展开全部
引用命名空间:
using System.Collections;
不行哈,ArrayList是System.Collections下的一个类型,而不是System.Collections.Generic下的,如果你不引用可以直接这么写:
System.Collections.ArrayList = new System.Collections.ArrayList(arr);
上面得也是对的
用using System.Collections.Generic就没有把ArrayList这个类型引用进去,会报错
using System.Collections;
不行哈,ArrayList是System.Collections下的一个类型,而不是System.Collections.Generic下的,如果你不引用可以直接这么写:
System.Collections.ArrayList = new System.Collections.ArrayList(arr);
上面得也是对的
用using System.Collections.Generic就没有把ArrayList这个类型引用进去,会报错
展开全部
{
public partial class Form1 : Form
{
ArrayList points;
Point currentPoint;
Pen thepen;
float penwidth;
SolidBrush thebrush;
private System.Windows.Forms.Button btnColor;
private System.Windows.Forms.ListBox lstPenStyle;
private System.Windows.Forms.CheckBox rbPen;
Color thecolor;
public Form1()
{
InitializeComponent();
currentPoint = new Point(50,10);
points = new ArrayList();
points.Add(currentPoint);
penwidth = 1;
thecolor = Color.Black;
thepen = new Pen(thecolor);
thebrush = new SolidBrush(thecolor);
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (currentPoint.X != e.X || currentPoint.Y != e.Y)
{
currentPoint.X = e.X;
currentPoint.Y = e.Y;
points.Add(currentPoint);
this.Invalidate();
this.Update();
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] ps=(Point[]) points.ToArray(typeof(Point));
if (rbLine.Checked)
g.DrawLine(Pens.Black, ps[0], ps[ps.Length - 1]);
else if (rbRectangle.Checked)
g.DrawRectangle(thepen, ps[0].X, ps[0].Y, ps[ps.Length - 1].X - ps[0].X, ps[ps.Length - 1].Y - ps[ps.Length - 1].Y);
else if (rbCurve.Checked)
g.DrawCurve(thepen, ps);
else if (rbPolygon.Checked)
g.DrawPolygon(thepen, ps);
else if (rbEllipse.Checked)
g.DrawEllipse(thepen,ps[0].X,ps[0].Y,ps[ps.Length-1].X-ps[0].X,ps[ps.Length-1].Y-ps[0].Y);
}
private void ChangeDrawType(object sender, PaintEventArgs e)
{
points.Clear();
currentPoint = new Point(50,10);
points.Add(currentPoint);
public partial class Form1 : Form
{
ArrayList points;
Point currentPoint;
Pen thepen;
float penwidth;
SolidBrush thebrush;
private System.Windows.Forms.Button btnColor;
private System.Windows.Forms.ListBox lstPenStyle;
private System.Windows.Forms.CheckBox rbPen;
Color thecolor;
public Form1()
{
InitializeComponent();
currentPoint = new Point(50,10);
points = new ArrayList();
points.Add(currentPoint);
penwidth = 1;
thecolor = Color.Black;
thepen = new Pen(thecolor);
thebrush = new SolidBrush(thecolor);
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (currentPoint.X != e.X || currentPoint.Y != e.Y)
{
currentPoint.X = e.X;
currentPoint.Y = e.Y;
points.Add(currentPoint);
this.Invalidate();
this.Update();
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] ps=(Point[]) points.ToArray(typeof(Point));
if (rbLine.Checked)
g.DrawLine(Pens.Black, ps[0], ps[ps.Length - 1]);
else if (rbRectangle.Checked)
g.DrawRectangle(thepen, ps[0].X, ps[0].Y, ps[ps.Length - 1].X - ps[0].X, ps[ps.Length - 1].Y - ps[ps.Length - 1].Y);
else if (rbCurve.Checked)
g.DrawCurve(thepen, ps);
else if (rbPolygon.Checked)
g.DrawPolygon(thepen, ps);
else if (rbEllipse.Checked)
g.DrawEllipse(thepen,ps[0].X,ps[0].Y,ps[ps.Length-1].X-ps[0].X,ps[ps.Length-1].Y-ps[0].Y);
}
private void ChangeDrawType(object sender, PaintEventArgs e)
{
points.Clear();
currentPoint = new Point(50,10);
points.Add(currentPoint);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询