類和類的引用5
namespace ConsoleApp2//主函數(shù)
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? Add ab = new Add();//引用加法類
? ? ? ? ? ? ab.a = 20;
? ? ? ? ? ? ab.b = 10;
? ? ? ? ? ? ab.Add1();
? ? ? ? ? ? Reduce ac = new Reduce();//引用減法類
? ? ? ? ? ? ac.a = 20;
? ? ? ? ? ? ac.b = 10;
? ? ? ? ? ? ac.Reduce1();
? ? ? ? ? ? Console.ReadKey();
? ? ? ? }
? ? }
}
============================================================
namespace ConsoleApp2
{
? ? class Add
? ? {
? ? ? ? public int a;//類的特征
? ? ? ? public int b;//類的特征
? ? ? ? public void Add1()
? ? ? ? {
? ? ? ? ? ? int ab = a + b;//類的邏輯,或者行為
? ? ? ? ? ? Console.WriteLine(ab);//類的邏輯,或者行為
? ? ? ? }
? ? }
}
============================================================
namespace ConsoleApp2
{
? ? class Reduce
? ? {
? ? ? ? public int a;//類的特征
? ? ? ? public int b;//類的特征
? ? ? ? public void Reduce1()
? ? ? ? {
? ? ? ? ? ? int ac = a * b;//類的邏輯,或者行為
? ? ? ? ? ? Console.WriteLine(ac);//類的邏輯,或者行為
? ? ? ? }
? ? }
}


