Declare PI as constant in CSharp
Description
The following code shows how to declare PI as constant.
Example
public class Example2_9
{/*from www .ja v a2 s .co m*/
public static void Main()
{
string helloWorld = "Hello World!";
System.Console.WriteLine(helloWorld);
helloWorld = "Hello World" + " from C#!";
System.Console.WriteLine(helloWorld);
helloWorld = "Hello World" + "\n from C#!";
System.Console.WriteLine(helloWorld);
const double Pi = 3.14159;
System.Console.WriteLine("Pi = " + Pi);
}
}
The code above generates the following result.