HelloWorld.Coordinate.TryCreate C# (CSharp) Method

TryCreate() public static method

尝试创建坐标对象
public static TryCreate ( int x, int y, Coordinate &coordinate ) : bool
x int
y int
coordinate Coordinate
return bool
        public static bool TryCreate( int x, int y, out Coordinate coordinate )
        {
            coordinate = null;

              if ( y % 2 != 0 )
            return false;

              if ( ( y / 2 ) % 2 == 0 && x % 2 != 0 )
            return false;

              if ( ( y / 2 ) % 2 != 0 && x % 2 == 0 )
            return false;

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

              return true;
        }