国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
    主站蜘蛛池模板: 威信县| 东海县| 海盐县| 岢岚县| 阿图什市| 宜君县| 镇原县| 朝阳县| 小金县| 石棉县| 札达县| 泉州市| 滨州市| 马关县| 通许县| 抚州市| 万年县| 满洲里市| 临沧市| 嘉兴市| 台中县| 惠来县| 循化| 河池市| 安平县| 江陵县| 扶风县| 广丰县| 平昌县| 屯昌县| 雷山县| 清徐县| 库车县| 巩义市| 沙田区| 建阳市| 慈溪市| 桑日县| 怀来县| 吴堡县| 安康市|