завершающий callback
const waitFor = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function test() {
await waitFor(1000);
return 1;
}
public override Base CreateCopy()
public override Derivative CreateCopy()
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
var objectBase = new Base("Base");
var objectDerivative = new Derivative("Derivative", '7');
var copyBase = objectBase.CreateCopy();
var copyDerivative = objectDerivative.CreateCopy();
Console.WriteLine(copyBase);
Console.WriteLine(copyDerivative);
}
}
public class Base
{
private readonly string _text;
public string Text
{
get { return _text; }
}
public Base(string text)
{
_text = text;
}
public virtual Base CreateCopy()
{
return new Base(Text);
}
public override string ToString()
{
return $"{nameof(Text)}: {Text}";
}
}
public class Derivative : Base
{
private readonly char _symbol;
public char Symbol
{
get { return _symbol; }
}
public Derivative(string text, char symbol)
: base(text)
{
_symbol = symbol;
}
public override Base CreateCopy()
{
return new Derivative(Text, Symbol);
}
public override string ToString()
{
return $"{nameof(Text)}: {Text}, {nameof(Symbol)}: {Symbol}";
}
}
}