using System;
public class HelloWorld
{
public static void Main()
{
private int myField;
public int MyProperty
{
get{return myField;}
set{myField = value;}
}
public int Add(int a=1,int b=1)
{
Add = a+b;
return Add;
}
Transformer t = Square;
Console.WriteLine($"The result of transformer is {t(3)}");
t = Cube;
Console.WriteLine($"The result of transformer is {t(3)}");
t += Square;
t(3);
}
public class Asset
{
public string Name;
}
public class Stock : Asset
{
public long SharesOwned;
}
public class House : Asset
{
public decimal Mortgage;
}
public static void display (Asset asset)
{
System.Console.WriteLine (asset.Name);
}
public class Asset2
{
public string Name;
public virtual decimal Liability => 0;
}
public class Stock1 : Asset2
{
public long SharesOwned;
}
public class House : Asset2
{
public decimal Mortgage;
public override decimal Liability => Mortgage;
}
public abstract class AbAsset
{
public abstract decimal NetValue { get; }
}
public class RealStock : AbAsset
{
public long SharesOwned;
public decimal CurrentPrice;
public override decimal NetValue => CurrentPrice * SharesOwned;
}
public class Stack
{
int position;
object[] data = new object[10];
public void Push (object obj) { data[position++] = obj; }
public object Pop() { return data[--position]; }
}
delegate int Transformer (int x);
static int Square (int x) {
int result = x * x;
Console.WriteLine($"The result of Square is {result}");
return result;
}
static int Cube (int x) {
int result = x * x * x;
Console.WriteLine($"The result of Cube is {result}");
return result;
}
}
class Rectangle
{
public readonly float Width, Height;
public Rectangle (float width, float height)
{
Width = width;
Height = height;
}
public void Deconstruct (out float width, out float height)
{
width = Width;
height = Height;
}
}
public static void duixiang{
Stock1 msft1 = new Stock1();
Asset asset = msft1;
Stock msft = new Stock();
Asset a = msft;
Stock s = (Stock)a;
Console.WriteLine (s.SharesOwned);
Console.WriteLine (s == a);
Console.WriteLine (s == msft);
}
public class PriceChangedEventArgs : EventArgs
{
public readonly decimal LastPrice;
public readonly decimal NewPrice;
public PriceChangedEventArgs (decimal lastPrice, decimal newPrice)
{
LastPrice = lastPrice; NewPrice = newPrice;
}
}
}