point.cs

来自「sqlserver scripts from ch 14 in zip file」· CS 代码 · 共 67 行

CS
67
字号
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;

[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.Native)]
public struct Point : INullable
{
    private int x;
    private int y;
    private bool isNull;

    public override string ToString()
    {
        return string.Format("{0}, {1}", this.x, this.y);
    }

    public bool IsNull
    {
        get
        {
            return this.isNull;
        }
    }

    public static Point Null
    {
        get
        {
            Point point = new Point();
            point.isNull = true;

            return point;
        }
    }

    public static Point Parse(SqlString s)
    {
        string[] coordinates = s.ToString().Split(new char[] { ',' });

        Point point = new Point();
        point.x = Convert.ToInt32(coordinates[0]);
        point.y = Convert.ToInt32(coordinates[1]);

        return point;
    }

    public int X
    {
        get
        {
            return this.x;
        }
    }

    public int Y
    {
        get
        {
            return this.y;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?