fork download
  1. using System;
  2. public class Sample{
  3. static string hoge = "class";
  4. public static void Main()
  5. {
  6. func1();
  7. func2();
  8. func3();
  9. }
  10.  
  11. static void func1()
  12. {
  13. Console.WriteLine(hoge); //=>class
  14. }
  15.  
  16. static void func2()
  17. {
  18. string hoge = "local2";
  19. Console.WriteLine(hoge);//=>local2
  20. }
  21.  
  22. static void func3()
  23. {
  24. //コメント外すとコンパイルエラー(CS0844)
  25. //javascriptならundefined
  26. /*
  27.   Console.WriteLine(hoge);
  28.   string hoge = "local3";
  29.   Console.WriteLine(hoge);
  30.   */
  31. }
  32. }
Success #stdin #stdout 0.03s 24120KB
stdin
Standard input is empty
stdout
class
local2