HelloWorld.Coordinate.Create C# (CSharp) Method

Create() public static method

创建一个坐标对象
public static Create ( int x, int y ) : Coordinate
x int
y int
return Coordinate
        public static Coordinate Create( int x, int y )
        {
            if ( y % 2 != 0 )
            throw new ArgumentException( "坐标 y 必须是偶数", "y" );

              if ( ( y / 2 ) % 2 == 0 && x % 2 != 0 )
            throw new ArgumentException( "当坐标 y/2 是偶数时,坐标 x 必须是偶数", "x" );

              if ( ( y / 2 ) % 2 != 0 && x % 2 == 0 )
            throw new ArgumentException( "当坐标 y/2 是奇数时,坐标 x 必须是奇数", "x" );

              return new Coordinate
              {
            X = x,
            Y = y,
              };
        }