My Prototype in C #

Source: Internet
Author: User
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) {}
}
};




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.