fork(1) download
  1. using System;
  2.  
  3. namespace MyNS {
  4. public class Console {
  5. public static void WriteLine(String s) {
  6. System.Console.WriteLine("[" + s + "]");
  7. }
  8. }
  9. }
  10.  
  11. public class Test
  12. {
  13. public static void Main()
  14. {
  15. String s = "Hello, world!";
  16. // using System;してるのでSystem.Console.WriteLineを省略して以下のようにかける
  17. Console.WriteLine(s);
  18. // 名前空間Systemと同名のメソッドを別の名前空間(ここではMyNS)には定義できる
  19. MyNS.Console.WriteLine(s);
  20. }
  21. }
Success #stdin #stdout 0.02s 16032KB
stdin
Standard input is empty
stdout
Hello, world!
[Hello, world!]