Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // 名前空間の登録
  2. using System; // 共通データ型と基本クラス(System名前空間)
  3.  
  4. // メインクラス
  5. class MainClass // MainClassクラスの定義
  6. {
  7.  
  8. // メインメソッド
  9. static void Main() // Mainメソッドの定義
  10. {
  11.  
  12. // string型とStringクラスのオブジェクトの宣言.
  13. string strType; // string型変数strType.
  14. String strClass; // StringクラスオブジェクトstrClass.
  15.  
  16. // 文字列の代入.
  17. strType = "ABC"; // strTypeに"ABC"を格納.
  18. strClass = "XYZ"; // strClassに"XYZ"を格納.(クラスだがnewがなくても"XYZ"でインスタンス生成される.)
  19.  
  20. // 型(クラス)名を出力.
  21. Console.WriteLine("strType: " + strType.GetType().ToString()); // strType.GetType().ToString()で取得できる型名を出力.
  22. Console.WriteLine("strClass: " + strClass.GetType().ToString()); // strClass.GetType().ToString()で取得できるクラス名を出力.
  23.  
  24. // 'B'が何文字目かを取得.
  25. int index = strType.IndexOf('B'); // strType.IndexOfでBの位置を取得.
  26. Console.WriteLine("index = " + index); // indexの値を出力.
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement