You cannot, in general. Everything related to the method call will not be a compile-time constant, as for the compiler.
What you can do is express a double literal using scientific notation:
public const double AvogadrosNumber = 6.022e-22;
So, in this particular case, you can write it without loss of readability.
In other settings, as long as the type is one of primitive types or decimal , you can simply write the constant as a literal and use a comment to explain how you got it. For example:
Note that even if method calls cannot be used in constant expressions, other operators may be used. For example:
// This is fine public const double PiSquared = Math.PI * Math.PI; // This is invalid public const double PiSquared = Math.Pow(Math.PI, 2);
For more information about what is allowed within a constant expression, see section 7.19 of the C # 5 specification.
Jon skeet
source share