NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

4.1.1 Default constructors

All value types implicitly declare a public parameterless constructor called the default constructor. The default constructor returns a zero-initialized instance known as the default value for the value type:

Like any other constructor, the default constructor of a value type is invoked using the new operator. In the example below, the i and j variables are both initialized to zero.

class A
{
   void F() {
      int i = 0;
      int j = new int();
   }
}

Because every value type implicitly has a public parameterless constructor, it is not possible for a struct type to contain an explicit declaration of a parameterless constructor. A struct type is however permitted to declare parameterized constructors. For example

struct Point
{
   int x, y;
   public Point(int x, int y) {
      this.x = x;
      this.y = y;
   }
}

Given the above declaration, the statements

Point p1 = new Point();
Point p2 = new Point(0, 0);

both create a Point with x and y initialized to zero.