X

getter setter 用法

以前只知道getter setter给类实例用,今天无意中发现,原来getter setter还可以给静态类调用。
示例:

package 
{

    /**
     * www.litefeel.com
     * lite3@qq.com
     * @author lite3
     */    public class getSetTest 
    {
        // 静态成员
        static private var _myWeb:String = "www.litefeel.com";

        // 非静态成员
        private var _myWeb:String = "www.litefeel.com";

        // 静态 getter setter
        static public function get myWeb():String { return _myWeb; }
        static public function set myWeb(value:String):void 
        {
            _myWeb = value;
        }

        // 非静态 getter setter
        public function get myWeb():String { return _myWeb; }
        public function set myWeb(value:String):void 
        {
            _myWeb = value;
        }
    }
}

This post was last modified on 2019 年 03 月 04 日 01:15

This website uses cookies.