国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

My Prototype in C#

2024-07-21 02:19:38
字體:
供稿:網(wǎng)友
  • 本文來源于網(wǎng)頁設(shè)計愛好者web開發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪問。
  • //myprototype
    using system;
    using system.collections;
    //abstract pagestyleprototype class 'prototype
    abstract class pagestyleprototype
    {
    //fields
    protected string stylestring;
    //properties
    public string stylestring
    {
    get{return stylestring;}
    set{stylestring=value;}
    }
    //methods
    abstract public pagestyleprototype clone();
    };
    //---pagestyle class---
    class pagestyle:pagestyleprototype
    {
    //constructor
    public pagestyle(string stylestr)
    {
    stylestring=stylestr;
    }
    override public pagestyleprototype clone()
    {
    return (pagestyleprototype)this.memberwiseclone();
    }

    public void displaystyle()
    {
    console.writeline(stylestring);
    }

    };
    //--------------------------------------------end of style class
    //stylemanager class
    class stylemanager
    {
    //fields
    protected hashtable styleht=new hashtable();
    protected pagestyleprototype styleref;

    //constructors
    public stylemanager()
    {
    styleref=new pagestyle("thefirststyle");
    styleht.add("style1",styleref);

    styleref=new pagestyle("thesecondstyle");
    styleht.add("style2",styleref);

    styleref=new pagestyle("thethirdstyle");
    styleht.add("style3",styleref);
    }

    //indexers
    public pagestyleprototype this[string key]
    {
    get{ return (pagestyleprototype)styleht[key];}
    set{ styleht.add(key,value);}
    }
    };
    //--------------------------------------------end of stylemanager class
    //testapp
    class testapp
    {
    public static void main(string[] args)
    {
    stylemanager stylemanager =new stylemanager();

    pagestyle stylea =(pagestyle)stylemanager["style1"].clone();
    pagestyle styleb =(pagestyle)stylemanager["style2"].clone();
    pagestyle stylec =(pagestyle)stylemanager["style3"].clone();

    stylemanager["style4"]=new pagestyle("theforthstyle");

    pagestyle styled =(pagestyle)stylemanager["style4"].clone();

    stylea.displaystyle();
    styleb.displaystyle();
    stylec.displaystyle();
    styled.displaystyle();

    while(true){}
    }
    };


    上一篇:My Singleton in C#

    下一篇:My FactoryMethod in C#

    發(fā)表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發(fā)表
    主站蜘蛛池模板: 沾化县| 龙口市| 塔河县| 濉溪县| 保定市| 定襄县| 扬州市| 潜江市| 永登县| 龙泉市| 班玛县| 江津市| 石棉县| 钟山县| 昭平县| 嵊州市| 灯塔市| 凯里市| 昌邑市| 桃园市| 花垣县| 黄龙县| 原阳县| 巴里| 阿拉善左旗| 都江堰市| 奉化市| 德化县| 海阳市| 齐河县| 遂川县| 万山特区| 祁连县| 盐山县| 康平县| 吐鲁番市| 昭平县| 汽车| 江永县| 塘沽区| 鞍山市|