程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#反省規范圖幅編號

C#反省規范圖幅編號

編輯:C#入門知識

C#反省規范圖幅編號。本站提示廣大學習愛好者:(C#反省規范圖幅編號)文章只能為提供參考,不一定能成為您想要的結果。以下是C#反省規范圖幅編號正文


/// <summary>
/// 反省能否為規范圖幅編號
/// </summary>
/// <param name="MapNumber">圖幅編號</param>
/// <returns>反省後果True/false</returns>
private bool CheckMapNumber(string MapNumber)
{
    int ColumnNumber100;
    if (MapNumber.Length == 3)//1:100萬圖幅規則
    {
        Regex RegMapNumber = new Regex(@"^[A-S]\d\d$");
        if (RegMapNumber.IsMatch(MapNumber.ToUpper()))
        {
            ColumnNumber100 = Convert.ToInt32(MapNumber.Substring(1, 2));
            if (ColumnNumber100 <= 60)
            { return true; }
        }
    }
    if (MapNumber.Length == 10)//其他圖幅規則
    {
        string ScaleMark = "";
        int ColumnNumber;
        int RowNumber;
        int RowMax = 0;
        int ColumnMax = 0;
        Regex RegMapNumber = new Regex(@"^[A-S]\d\d[B-H]\d\d\d\d\d\d$");
        if (RegMapNumber.IsMatch(MapNumber.ToUpper()))
        {
            ScaleMark = MapNumber.Substring(3, 1);
            switch(ScaleMark)
            {
                case "B":
                    RowMax = 2;
                    ColumnMax = 2;
                    break;
                case "C":
                    RowMax = 4;
                    ColumnMax = 4;
                    break;
                case "D":
                    RowMax = 12;
                    ColumnMax = 12;
                    break;
                case "E":
                    RowMax = 24;
                    ColumnMax = 24;
                    break;
                case "F":
                    RowMax = 48;
                    ColumnMax = 48;
                    break;
                case "G":
                    RowMax = 96;
                    ColumnMax = 96;
                    break;
                case "H":
                    RowMax = 192;
                    ColumnMax = 192;
                    break;
                default:
                    RowMax = 0;
                    ColumnMax = 0;
                    break;
            }
            ColumnNumber100 = Convert.ToInt32(MapNumber.Substring(1, 2));
            RowNumber = Convert.ToInt32(MapNumber.Substring(4, 3));
            ColumnNumber = Convert.ToInt32(MapNumber.Substring(7, 3));
            if (ColumnNumber100 <= 60 && RowNumber <= RowMax && ColumnNumber <= ColumnMax)
            { return true; }
        }
    }
    return false;
}

  

  1. 上一頁:
  2. 下一頁: