https://pastein.ru/t/qY
скопируйте уникальную ссылку для отправки
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ticket_12
{
class Program
{
internal class T
{
protected string Ts;
public string ts
{
get
{
return Ts;
}
}
public T()
{
this.Ts = "T";
}
public virtual void output()
{
Console.WriteLine("This is a {0} class", this.ts);
}
~T(){}
}
internal class Y: T
{
public Y() : base()
{
this.Ts = "Y";
}
public override void output()
{
Console.WriteLine("This is a {0} class", this.ts);
}
}
internal class Client
{
private string s = "";
public string S
{
get
{
return s;
}
}
public Client(string s)
{
this.s = "s";
}
public void showStr()
{
Console.WriteLine("Current value of g field of the Client: {0}", this.S);
}
}
internal class Server
{
private static int n = 0;
public int N
{
get
{
return n;
}
}
public Server(){}
public void ShowState()
{
Console.WriteLine("Current number of clients connected to the Server: {0}", this.N);
}
public void AddClient(Client c)
{
n++;
Console.WriteLine("The client {0} has added", c.S);
}
}
static void Main(string[] args)
{
T t1 = new T();
Y y = new Y();
if (t1 is T) { t1.output();}
t1 = new Y();
if (t1 is Y) { t1.output(); }
t1.GetType();
t1 = new T();
/*t1.output();
y.output();
ClassOutput(t1);
ClassOutput(y);
*/
Client c1 = new Client("Tom"), c2 = new Client("Jane"), c3 = new Client("Eugene");
Server s = new Server();
s.ShowState();
s.AddClient(c1);
s.AddClient(c2);
s.AddClient(c3);
s.ShowState();
Console.ReadKey();
}
static public void ClassOutput(T t)
{
t.output();
}
}
}