I am trying to declare a PI constant like this:
public static const double PI = Math.PI;
but why am I getting this error?
The constant 'Calendar.NewCalendar.PI' cannot be marked static
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
constimpliesstatic(you don’t need an instance to reference theconstvalue).I want to also add this important point: When you link against (reference) an assembly with a
public const, that value is copied into your assembly. So if theconstvalue in the referenced assembly changes, your assembly will still have the originally compiled-in value.If this behavior is not acceptable, then you should consider making the field a
public static readonlyfield.Lib.dll, provided as binary:
App.exe, references Lib.dll:
From MSDN:
From DotNetPerls: