//By prefixing the field with the const keyword, you can declare that a field is static but that its value can never change
//A const field does not use the static keyword in its declaration but is nevertheless static
//example
class Math
{
...
public const double PI = 3.14159265358979323846;
}
//A static class can contain only static members
//A static class cannot contain any instance data or methods
//example
public static class Math
{
public static double Sin(double x) {...}
public static double Cos(double x) {...}
public static double Sqrt(double x) {...}
...
}
//when decalre a method static, then no need to instanciate and object of that class where that method is located
//example of static
//method Sqrt is called from class Math without instanciate an object
public double DistanceTo(Point other)
{
int xDiff = this.x - other.x;
int yDiff = this.y - other.y;
double distance = Math.Sqrt((xDiff * xDiff) + (yDiff * yDiff));
}
//example without static
Math m = new Math();
double d = m.Sqrt(42.24);