Head First C#
頭とからだで覚えるC#の基本
(オライリージャパン)
Andrew Stellman (著), Jennifer Green (著)
佐藤 嘉一 (監修), 木下 哲也 (翻訳)
開発環境
- Microsoft Windows 8.1 Pro (VMware Fusion 6, OS X Mavericks - Apple) (OS)
- C# (プログラミング言語)
- Microsoft Visual Studio Express 2013 for Windows Desktop (統合開発環境, IDE)
Head First C#―頭とからだで覚えるC#の基本 (Andrew Stellman (著)、Jennifer Green (著)、佐藤 嘉一 (監修)、木下 哲也 (翻訳)、オライリージャパン)の2章(あくまでコードである)、コードマグネット(p.74)を解いてみる。
コードマグネット(p.74)
コード
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
string Result = "";
int x = 3;
if (x > 2)
{
Result = Result + "a";
}
x = x - 1;
Result = Result + "-";
if (x == 2)
{
Result = Result + "b c";
}
x = x - 1;
Result = Result + "-";
if (x == 1)
{
Result = Result + "d";
x = x - 1;
}
MessageBox.Show(Result);
}
}
}
0 コメント:
コメントを投稿