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);
}
}
}
展开
 我来答
老马哥2
2012-04-10
知道答主
回答量:1
采纳率:0%
帮助的人:1640
展开全部
引用命名空间:
using System.Collections;

不行哈,ArrayList是System.Collections下的一个类型,而不是System.Collections.Generic下的,如果你不引用可以直接这么写:
System.Collections.ArrayList = new System.Collections.ArrayList(arr);
上面得也是对的

用using System.Collections.Generic就没有把ArrayList这个类型引用进去,会报错
龍城少壞
2007-10-27
知道答主
回答量:8
采纳率:0%
帮助的人:0
展开全部
{
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);
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式