2018年3月19日月曜日

開発環境

Head First C# ―頭とからだで覚えるC#の基本 (Andrew Stellman (著)、Jennifer Greene (著)、佐藤 嘉一 (監修, 監修)、木下 哲也 (翻訳)、オライリージャパン)の2章(あくまでコードである - 内部では)、コードマグネット(p. 74)を取り組んでみる。

コード

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    static class Program
    {
        /// <summary>
        /// アプリケーションのメイン エントリ ポイントです。
        /// </summary>
        [STAThread]
        static void Main()
        {
            /*
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
            */
            string result = "";
            int x = 3;
            while (x > 0)
            {
                if (x > 2)
                {
                    result += "a";
                }
                x -= 1;
                result += "-";
                if (x == 2)
                {
                    result += "b c";
                }
                if (x == 1)
                {
                    result += 'd';
                    x -= 1;
                }
            }

            MessageBox.Show(result);
        }
    }
}

実行結果

0 コメント:

コメントを投稿