コード例 #1
0
        static void Main(string[] args)
        {
            const string NAME    = "Object Name";
            const float  BALANCE = 597878.032f;

            BankAccountStruct structAccount = new BankAccountStruct(NAME, BALANCE);

            BankAccountClass classAccount = new BankAccountClass(NAME, BALANCE);

            BankAccountStruct copyStructAccount = structAccount;
            BankAccountClass  copyClassAccount  = classAccount;


            Add100(structAccount);
            structAccount.ShowDetails("Original Struct Account");
            Add100(classAccount);
            copyStructAccount.ShowDetails("Original Class Account");

            structAccount.Balance = Add100(structAccount.Balance);
            classAccount.Balance  = Add100(classAccount.Balance);


            Console.WriteLine();
            classAccount.ShowDetails("Original Struct Account");
            copyClassAccount.ShowDetails("Original Class Account");

            copyStructAccount.AddMonthlyInterest();
            copyClassAccount.AddMonthlyInterest();
            Console.WriteLine("-----------------------------");
            structAccount.ShowDetails("Original Struct Account");
            copyStructAccount.ShowDetails("Original Class Account");
            Console.WriteLine();
            classAccount.ShowDetails("Original Struct Account");
            copyClassAccount.ShowDetails("Original Class Account");

            Console.ReadLine();
        }
コード例 #2
0
 static void Add100(BankAccountClass classAccount)
 {
     classAccount.Balance += 10000000;
 }