感謝您的回覆
我照您的方式在副函式類別這樣寫結構
結果有一個小錯誤,想再提出討論一下,
錯誤如下:
※ 引述《chrisQQ (ChrisLiu)》之銘言:
: yes 問題如 remmurds 板友所說
: 改成這樣可能會好一點
: public struct rectangleInfo
: {
: private Point _topLeft, _topRight, _bottomLeft, _bottomRight;
: public rectangleInfo()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
這裡出現訊息 錯誤1 結構無法包含明確無參數的建構函式
: {
: 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; }
: }
: }
我自己查一些資料,在msdn上似乎是說一定要有輸入參數的表示
我找不到其他解法,就自己隨便編了一個輸入參數試試看 XDD
我寫成這樣
public rectangleInfo( int x)
^^^^^^^^^
多寫了這部分
神奇的是除錯可以通過............XDD
但其實我也不知道在這裡的參數有什麼作用,
也沒有真的傳一個值進去(因為不知道在那裡輸入...)
意外的是在主程式仍可接收到長方形座標回傳正確值(感謝~)
但自己是有點擔心我這樣寫會不會有什麼不可預期的問題..
所以請教各位是否有遇過這樣的情況~
或是有沒有要修正的觀念~
謝謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.163.249