My Prototype in C #

zhaozj2021-02-16  102

// MyPrototypeusing System; using System.Collections; // abstract PageStylePrototype Class' Prototypeabstract 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 Of STYLE CLASS // StyleManager ClassClass StyleManager {// Fields Protected Hashtable StyleHT = New HashTable (); protected by protected

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

Styleref = New Pagestyle; Styleht.Add ("style2", styleref); Styleref = New PageStyle ("TthirdStyle"); Styleht.Add ("style3", styleref);}

// Indexers Public PageStylePrototype this [String Key] {Get {Return (PageStylePrototype) Styleht [key];} set {styleht.add (key, value);}}}; // ---------- --------------------------------- end of stylemanager class // testappclass testapp {public static void main (String " ] args) {StyleManager StyleManager = New StyleManager ();

PageStyle Style = (PageStyle) StyleManager ["Style1"]. Clone (); PageStyle Styleb = (PageStyle) StyleManager ["Style2"]. Clone (); PageStyle StyleStyle ;

stylemanager [ "style4"] = new PageStyle ( "theforthstyle");. PageStyle styled = (PageStyle) stylemanager [ "style4"] Clone (); stylea.DisplayStyle (); styleb.DisplayStyle (); stylec.DisplayStyle (); STYLED.DISPLAYSTYLE ();

While (TRUE) {}}};

转载请注明原文地址:https://www.9cbs.com/read-10201.html

New Post(0)