2018年8月25日土曜日

開発環境

初めてのC# 第2版 (Jesse Liberty (著)、Brian MacDonald (著)日向 俊二 (翻訳)、オライリージャパン)の8章(メソッド)、8.5(練習問題)、問題8-2.を取り組んでみる。

コード

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 20;

            DoubleAndTriple(ref a, ref b);

            Console.WriteLine(a);
            Console.WriteLine(b);
        }
        public static void DoubleAndTriple(ref int x, ref int y)
        {
            x = 2 * x;
            y = 3 * y;
        }
    }
}

入出力結果(コマンドプロンプト)

20
60
続行するには何かキーを押してください . . .

0 コメント:

コメントを投稿