close
   1: static void Main(string[] args)
   2:  {
   3:      var v1 = f1();
   4:      var avg1 = v1 / 3;
   5:      Console.WriteLine($"{avg1.GetType().Name}, avg: {avg1}");
   6:  
   7:      var v2 = f2();
   8:      var avg2 = v2 / 3;
   9:      Console.WriteLine($"{avg2.GetType().Name}, avg: {avg2}");
  10:  
  11:      var v3 = f3();
  12:      var avg3 = v3 / 3;
  13:      Console.WriteLine($"{avg3.GetType().Name}, avg: {avg3}");
  14:  
  15:      var v4 = f4();
  16:      var avg4 = v4 / 3;
  17:      Console.WriteLine($"{avg4.GetType().Name}, avg: {avg4}");
  18:  
  19:      var v5 = f5();
  20:      var avg5 = v5 / 3;
  21:      Console.WriteLine($"{avg5.GetType().Name}, avg: {avg5}");
  22:      Console.ReadKey();
  23:  }
  24:  static double f1()
  25:  {
  26:      double x = 100;
  27:      return x;
  28:  }
  29:  static float f2()
  30:  {
  31:      float x = 100;
  32:      return x;
  33:  }
  34:  static decimal f3()
  35:  {
  36:      decimal x = 100;
  37:      return x;
  38:  }
  39:  static long f4()
  40:  {
  41:      long x = 100;
  42:      return x;
  43:  }
  44:  static Int32 f5()
  45:  {
  46:      Int32 x = 100;
  47:      return x;
  48:  }


image



參考資料

1. C# - var 隱含型別(Implicitly Typed) vs 顯式型別(Explicitly Typed)

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()