找回密码
 立即注册

只需一扫,快速开始

QQ登录

只需一步,快速开始

搜索
查看: 40914|回复: 0

[使用问题] 测试代码高亮(请高手回答)

  [复制链接]

1

主题

0

回帖

12

积分

新手站长

积分
12
发表于 2020-4-24 16:41:37 | 显示全部楼层 |阅读模式

本帖最后由 inside 于 2020-4-24 17:14 编辑

代码提示在预览的时候是可以高亮显示的,为什么在发布后就不行了?

  • 1.Prototype 抽象原型 2.ConcretePrototype1 具体原型(实现 Prototype) 3.Client

# 编辑时 微信截图_20200424163758.png

发布后

微信截图_20200424163944.png

using System;
/// 

/// C#语言
///  
namespace DesignMode
{
//抽象原型
abstract class Prototype
{
private string id;
public Prototype(string id)
{
this.id = id;
}
public string Id
{
get { return id; }
}
public abstract Prototype Clone();
}
//具体原型 1
class ConcretePrototype1rototype
{
    public ConcretePrototype1(string id) : base(id)
    {

    }
    public override Prototype Clone()
    {
        return new ConcretePrototype1(this.Id) as Prototype;
    }
} 

//具体原型种类 2
class ConcretePrototype2 : Prototype
{
    private string name;
    public string Name { get { return name; } }
    private int age;
    public int Age { get { return age; } }
    public ConcretePrototype2(string id, string name, int age) : base(id)
    {
        this.name = name;
        this.age = age;
    }
    public override Prototype Clone()
    {
        return new ConcretePrototype2(this.Id, this.Name, this.Age) as Prototype;
    }
}

//客户端测试代码
class Client
{
    public void Test()
    {
        ConcretePrototype1 p1 = new ConcretePrototype1(&quotrototype1");
        ConcretePrototype1 c11 = p1.Clone() as ConcretePrototype1;
        ConcretePrototype1 c12 = p1.Clone() as ConcretePrototype1;

        ConcretePrototype2 p2 = new ConcretePrototype2(&quotrototype2", "种类 2", 18);
        ConcretePrototype2 c21 = p2.Clone() as ConcretePrototype2;
        ConcretePrototype2 c22 = p2.Clone() as ConcretePrototype2;
        Console.WriteLine("原型 1{0}", p1.Id);
        Console.WriteLine("原型 1 克隆{0}", c11.Id);
        Console.WriteLine("原型 1 克隆{0}", c12.Id);

        Console.WriteLine("原型 2{0},{1},{2}", p2.Id, p2.Name, p2.Age);
        Console.WriteLine("原型 2 克隆{0},{1},{2}", c21.Id, c21.Name, c21.Age);
        Console.WriteLine("原型 2 克隆{0},{1},{2}", c22.Id, c22.Name, c22.Age);
    }
}

class Program
{
    static void Main(string[] args)
    {
        Client client = new Client();
        client.Test();
        Console.Read();
    }
}

}

void menu() { printf("##########################\n"); printf("## 欢迎来到扫雷游戏 ##\n"); printf("##########################\n"); printf("#1.开始游戏 2.结束游戏#\n"); printf("##########################\n"); printf("您的选择是"); }

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册   

×
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册   

本版积分规则

QQ|Archiver|手机版|小黑屋|站秘书 ( 蜀ICP备15034504号-3 )

GMT+8, 2024-4-26 01:10 , Processed in 0.089064 second(s), 41 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表