⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace _1
{
    abstract class ColorRGBPrototype
    {
        public abstract ColorRGBPrototype Clone();
    }
    class ColorRGB : ColorRGBPrototype
    {
        private int red, green, blue;
        public ColorRGB(int red, int green, int blue)
        {
            this.red = red;
            this.green = green;
            this.blue = blue;
        }
        public override ColorRGBPrototype Clone()
        {
            return (ColorRGBPrototype)this.MemberwiseClone();
        }

        public void Display()
        {
            Console.WriteLine("颜色值: {0},{1},{2}",
              red, green, blue);
        }
    }
    class ColorRGBManager
    {
        Hashtable colors = new Hashtable();
        public ColorRGBPrototype this[string name]
        {
            get { return (ColorRGBPrototype)colors[name]; }
            set { colors.Add(name, value); }
        }
    }
    class PrototypeApp
    {
        public static void Main(string[] args)
        {
            ColorRGBManager colormanager = new ColorRGBManager();
            colormanager["red"] = new ColorRGB(255, 0, 0);
            colormanager["green"] = new ColorRGB(0, 255, 0);
            colormanager["blue"] = new ColorRGB(0, 0, 255);
            string colorName = "red";   //开始克隆
            ColorRGB red = (ColorRGB)colormanager[colorName].Clone();
            red.Display();
            colorName = "green";
            ColorRGB green = (ColorRGB)colormanager[colorName].Clone();
            green.Display();
            colorName = "blue";
            ColorRGB blue = (ColorRGB)colormanager[colorName].Clone();
            blue.Display();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -