如何查看System.Math.Sin的源代码?

kis*_*pit 6 .net c# clr

在这个链接中,我们可以看到System.Math类的源代码.但我找不到正弦定义的源代码.

这里有什么我想念的吗?

Pat*_*man 9

该方法的签名是:

  [System.Security.SecuritySafeCritical]  // auto-generated
  [ResourceExposure(ResourceScope.None)]
  [MethodImplAttribute(MethodImplOptions.InternalCall)]
  public static extern double Sin(double a);
Run Code Online (Sandbox Code Playgroud)

extern该方法中意味着它是别处定义.在这种情况下,它将直接在CLR中实现(可能用C或汇编语言编写),这意味着没有可用的.NET实现.

  • 看看Hans Passant关于"Math"课程中另一个函数的答案.http://stackoverflow.com/questions/8870442/how-is-math-pow-implemented-in-net-framework/8870593#8870593.这是关于`Math.Exp`但我想同样适用于所有基本的数学运算. (3认同)

D S*_*ley 5

您无法想到.NET Framework源代码 - 它是一个extern函数,这意味着它是在较低级别的库中实现的(可能是CLR本身,但我不确定).

您可以尝试使用共享源CLI