C_Sharp 板


LINE

: 请问这样可以将每个长方形座标都存进rInfo吗? 理论上可以ˇˇ : (共有ObjectNum个长方形,希望知道长方形谁是谁) 知道谁是谁的定义是?你每个长方形有自己的名字嘛? 在 ArrayList 中,长方形的顺序就是你加入的顺序 : 如果我要在主函式取出每个长方形的座标 : 请问要如何一个一个分别取出不同的长方形呢? : 是用for回圈一个一个选出长方形,再提出座标吗? 我原文中是用 foreach 来取出每个长方形,之後再提出座标 你要用 for 的话,应该是这样写 for (int i = 0;i < rectArray.Size ; i++) { rectangleInfo ri = (rectangleInfo) rectAray[i]; // ri.topLeft // ri.topRight // 看你要怎麽操作了 } /* 呃,虽然有点不负责任,但如果 rectArray.Size 错的话, 那可能是 rectArray.Length 平常用的 IDE 都有提示语法… 所以没有很仔细记得哪个是 C# 哪个是 Java 的用法… 不好意思 >""< 另外我都是凭着印象写的… 还有问题的话,我过两天再 review code… */ : 麻烦您的赐教~ : 再次感谢~
1F:→ a761007:他的写法是C# 3.0才有的 01/02 21:17
2F:→ remmurds:因为Point结构需要透过new关键字产生实体 如果你只有宣告 01/02 23:03
3F:→ remmurds:public Point p { get; set; } 当然会产生编译错误 01/02 23:05
4F:→ remmurds:这跟.Net Framework是不是3.0版没啥关联 01/02 23:07
5F:→ remmurds:也跟set/get写法没啥关连 C#的存取子向来都是长成那样 01/02 23:09
yes 问题如 remmurds 板友所说 改成这样可能会好一点 public struct rectangleInfo { private Point _topLeft, _topRight, _bottomLeft, _bottomRight; public rectangleInfo() { this._topLeft = new Point(); this._topRight = new Point(); this._bottomLeft = new Point(); this._botomRight = new Point(); } // 也可以在 constructor 就把各点的座标丢进去 // 就在依照你希望的格式建个 constructor 罗~ public Point topLeft { get { return _topLeft; } set { this._topLeft = value; } } public Point topRight { get { return _topRight; } set { this._topRight = value; } } public Point bottomLeft { get { return _bottomLeft; } set { this._bottomLeft = value; } } public Point bottomRight { get { return _bottomRight; } set { this._bottomRight = value; } } } --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.145.202.66 ※ 编辑: chrisQQ 来自: 203.145.202.66 (01/03 00:39) ※ 编辑: chrisQQ 来自: 203.145.202.66 (01/03 00:47)







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Boy-Girl站内搜寻

TOP