プログラム言語 変数

エスケープ

頭に「\」を付ける
\' シングルクォーテーション
\" ダブルクォーテーション
\\ \記号
\n 改行
\r リターン
\b バックスペース
\t 水平タブ
\0 NULL文字を表す

値渡し・参照渡し

public void myForm_Load(object sender, EventArgs e)
{
  int a = 10;
  int b = 10;
  int c = 10;
  SubRoutine(prmA: a, ref refB: b, outC: out c);

  MessageBox.Show(text: a.ToString()); ⇒10(値渡し)
  MessageBox.Show(text: b.ToString()); ⇒100(参照渡し)
  MessageBox.Show(text: c.ToString()); ⇒1000(参照渡し)
}

private void SubRoutine(int prmA, ref int refB, out int outC)
{
  prmA *= 10;
  refB *= 10;

  //outはサブルーチン内で必ず初期化しなければならない
  int d = outC; outCに値を入れる前に処理しているので×
  outC *= 10; 同じく×
  outC = 1000; OK(outCは参照渡し)
}

変数名

命名規則
・予約語(if、class等)は使えない。
・数字から初めてはいけない。
・記号は「_」、通貨記号(「¥」,「$」,「£」,「€」等)のみ