推扬网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
推扬网 门户 你问我答 查看内容

江小娟:c#错误1:找不到类型或命名空间名称“ArrayList”(是否缺少 using 指令或程序 ...

2020-8-12 17:44| 发布者: admin| 查看: 124| 评论: 0

摘要: 董鹏的回答: 引用命名空间: using System.Collections; 不行哈,ArrayList是System.Collections下的一个类型,而不是System.Collections.Generic下的,如果你不引用可以直接这么写: System.Collections.ArrayList ...

董鹏的回答:

引用命名空间: 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这个类型引用进去,会报错

刘老大的回答:

using system.collections;

张玉平的回答:

{ 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);


鲜花

握手

雷人

路过

鸡蛋

最新评论

热门推荐
最新资讯

广告服务|投稿要求|禁言标准|版权说明|免责声明|手机版|小黑屋|推扬网 ( 粤ICP备18134897号 )|网站地图 | 邮箱:vayae@hotmail.com

GMT+8, 2025-5-1 18:11 , Processed in 0.059908 second(s), 29 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

返回顶部