标题:[求助]类中的方法问题
只看楼主
sun_life
Rank: 1
等 级:新手上路
帖 子:356
专家分:5
注 册:2006-5-29
结帖率:72.73%
 问题点数:0 回复次数:0 
[求助]类中的方法问题
我写了三个方法,被注视掉的方法没问题,但是把被注视掉的方法分解成两个(也就是后两个)就不对了
namespace managementStudents
{
    class c_IDCard          //身份证号验证
    {
        string str_IDCard;

        bool b_IDCardEmpty;

        bool b_IDCardJudgment;

        bool b_IDCardEmptyJudgment;

        public c_IDCard(string str)
        {
            str_IDCard = str.Trim();     //str.Trim()去掉str_IDCard中的左右空格
        }

        /*public bool IDCard_EmptyJudgment()      //判断输入是不是不够18位
        {
            int i;

            if (str_IDCard.Length == 18)    //判断输入是不是不够18位     
            {
                if (char.IsNumber(str_IDCard,17)||str_IDCard[17]=='x'||str_IDCard[17]=='y'||str_IDCard[17]=='X'||str_IDCard[17]=='Y') //最后一位为数字或x,y(大小写)     
                {
                    for (i = 0; i < 17; i++)    //判断前17位是不是纯数字
                    {
                        if (char.IsNumber(str_IDCard, i))
                        {
                            b_IDCardEmptyJudgment = true;
                        }
                        else
                        {
                            b_IDCardEmptyJudgment = false;

                            break;
                        }
                    }
                }
            }
            else
            {
                b_IDCardEmptyJudgment = false;
            }
            return b_IDCardEmptyJudgment;
        }*/

        public bool IDCard_Empty()
        {
            if (str_IDCard.Length == 18)
            {
                b_IDCardEmpty = true;
            }
            else
            {
                b_IDCardJudgment = false;
            }
            return b_IDCardJudgment;
        }

        public bool IDCard_Judgment()
        {
            int i;

            if(b_IDCardEmpty)
            {
                if (char.IsNumber(str_IDCard,17)||str_IDCard[17]=='x'||str_IDCard[17]=='y'||str_IDCard[17]=='X'||str_IDCard[17]=='Y') //最后一位为数字或x,y(大小写)     
                {
                    for (i = 0; i < 17; i++)    //判断前17位是不是纯数字
                    {
                        if (char.IsNumber(str_IDCard, i))
                        {
                            b_IDCardEmptyJudgment = true;
                        }
                        else
                        {
                            b_IDCardEmptyJudgment = false;

                            break;
                        }
                    }
                }
            }
            else
            {
                b_IDCardEmptyJudgment = false;
            }
            return b_IDCardEmptyJudgment;
        }


    }
}
2008-10-15 15:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-238432-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.205958 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved