コード例 #1
0
ファイル: OopClasses.cs プロジェクト: AnnaSava/MetanitSharp
        static void staticField()
        {
            AccountGeneric <int> account1 = new AccountGeneric <int> {
                Sum = 5000
            };

            AccountGeneric <int> .session = 5436;

            AccountGeneric <string> account2 = new AccountGeneric <string> {
                Sum = 4000
            };

            AccountGeneric <string> .session = "45245";

            Console.WriteLine(AccountGeneric <int> .session);      // 5436
            Console.WriteLine(AccountGeneric <string> .session);   // 45245
        }
コード例 #2
0
ファイル: OopClasses.cs プロジェクト: AnnaSava/MetanitSharp
        static void genericId()
        {
            AccountGeneric <int> account1 = new AccountGeneric <int> {
                Sum = 5000
            };
            AccountGeneric <string> account2 = new AccountGeneric <string> {
                Sum = 4000
            };

            account1.Id = 2;          // упаковка не нужна
            account2.Id = "4356";
            int    id1 = account1.Id; // распаковка не нужна
            string id2 = account2.Id;

            Console.WriteLine(id1);
            Console.WriteLine(id2);
        }
コード例 #3
0
ファイル: OopClasses.cs プロジェクト: AnnaSava/MetanitSharp
        static void multipleParams()
        {
            AccountGeneric <int> acc1 = new AccountGeneric <int> {
                Id = 1857, Sum = 4500
            };
            AccountGeneric <int> acc2 = new AccountGeneric <int> {
                Id = 3453, Sum = 5000
            };

            Transaction <AccountGeneric <int>, string> transaction1 = new Transaction <AccountGeneric <int>, string>
            {
                FromAccount = acc1,
                ToAccount   = acc2,
                Code        = "45478758",
                Sum         = 900
            };

            Console.WriteLine($"Транзакция {transaction1.Code} от {transaction1.FromAccount.Id} к {transaction1.ToAccount.Id} на сумму {transaction1.Sum}");
        }