Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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. // int型とInt32構造体のオブジェクトの宣言.
  13. int intType; // int型変数intType.
  14. Int32 intStruct; // Int32型構造体変数intStruct.
  15. int intAfter; // int型変数intAfter.
  16.  
  17. // 値の代入.(ここでintTypeやintStructに値を設定したインスタンスがコピーされるので, これ以前ではメソッドを呼べない.)
  18. intType = 10; // intTypeに10を代入.
  19. intStruct = 100; // intStructに100を代入.
  20.  
  21. // 型(構造体)名を出力.
  22. Console.WriteLine("intType: " + intType.GetType().ToString()); // intType.GetType().ToString()で取得できる型名を出力.
  23. Console.WriteLine("intStruct: " + intStruct.GetType().ToString()); // intStruct.GetType().ToString()で取得できる構造体名を出力.
  24.  
  25. // 文字列をパースして, 数値を取得.
  26. intAfter = Int32.Parse("123"); // Int32.Parseで"123"をパースして, 数値123をintAfterに代入.
  27. Console.WriteLine("intAfter = " + intAfter); // Console.WriteLineでintAfterを出力.
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement