C# 中的 MathF.Exp() 方法示例

csharpserver side programmingprogramming更新于 2025/8/12 14:37:17

C# 中的 MathF.Exp() 方法返回指定幂的乘积。

语法

以下是语法 −

public static float Exp (float val);

以上,Val 是浮点数。

示例

现在让我们看一个实现 MathF.Exp() 方法的示例 −

using System;
class Demo {
   public static void Main(){
      float val = 90f;
      float res = MathF.Exp(val);
      Console.WriteLine("MathF.Exp() = "+res);
   }
}

输出

这将产生以下输出 −

MathF.Exp() = Infinity

示例

现在让我们看另一个实现 MathF.Exp() 方法的示例 −

using System;
class Demo {
   public static void Main(){
      float val = 0.00f;
      float res = MathF.Exp(val);
      Console.WriteLine("MathF.Exp() = "+res);
   }
}

输出

这将产生以下输出 −

MathF.Exp() = 1

相关文章