using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 泛型
{
class Program
{
static void Main(string[] args)
{
aaa.a();
}
}
public class aaa
{
public static void a()
{
Brid brid = Brid.brid();
Console.WriteLine(brid.i);
int a=plane.Instance.j;
Console.WriteLine(a);
//int b = BT.bt.a;
//Console.WriteLine(b);
int c=? TapEvent.inst.c;
Console.WriteLine(c);
Console.ReadKey();
}
}
class plane//單例
{
public int j = 20;
private static plane mInstance;
public static plane Instance
{
get
{
if (null == mInstance) mInstance = new plane();
return mInstance;
}
}
public void StartGame()
{
Console.WriteLine("plane單例被調用了舷丹!");
}
}
public? class Brid//單例
{
public int i = 10;
private static Brid mBrid = null;
public static Brid brid()
{
if (mBrid == null) mBrid = new Brid();
return mBrid;
}
public void StartGame()
{
Console.WriteLine("brid單例被調用了秽梅!");
Console.ReadKey();
}
}
class BT//單例
{
public int a = 30;
private static BT mbt;
public static BT bt
{
get { return mbt; }
set { mbt = value; }
}
void start()
{
mbt = this;
}
}
class TapEvent//單例
{
public int c = 40;
private static TapEvent _Inst;
public static TapEvent inst { get { return _Inst; } }
}
}