标题:求C#段代码表达意思
只看楼主
boyving
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-11-28
结帖率:0
已结贴  问题点数:20 回复次数:3 
求C#段代码表达意思


private void Freg_Load(object sender, EventArgs e)
{
    this.label2.Visible = false;
    this.Text1.Text = this.getCpu() + this.GetDiskVolumeSerialNumber();
    this.Text1.Text = this.Text1.Text.Substring(2, 7) + this.Text1.Text.Substring(15, 8);
    string text = "";
    text = this.Text1.Text;
    string[] strArray = new string[0x19];
    string str2 = "";
    for (int i = 5; i < 14; i++)
    {
        strArray[i] = text.Substring(i, 1);
        if (strArray[i] == "0")
        {
            strArray[i] = "0";
        }
        else if (strArray[i] == "1")
        {
            strArray[i] = "1";
        }
        else if (strArray[i] == "2")
        {
            strArray[i] = "2";
        }
        else if (strArray[i] == "3")
        {
            strArray[i] = "3";
        }
        else if (strArray[i] == "4")
        {
            strArray[i] = "4";
        }
        else if (strArray[i] == "5")
        {
            strArray[i] = "5";
        }
        else if (strArray[i] == "6")
        {
            strArray[i] = "6";
        }
        else if (strArray[i] == "7")
        {
            strArray[i] = "7";
        }
        else if (strArray[i] == "8")
        {
            strArray[i] = "8";
        }
        else if (strArray[i] == "9")
        {
            strArray[i] = "9";
        }
        else if (strArray[i] == "A")
        {
            strArray[i] = "0";
        }
        else if (strArray[i] == "B")
        {
            strArray[i] = "1";
        }
        else if (strArray[i] == "C")
        {
            strArray[i] = "2";
        }
        else if (strArray[i] == "D")
        {
            strArray[i] = "3";
        }
        else if (strArray[i] == "E")
        {
            strArray[i] = "4";
        }
        else if (strArray[i] == "F")
        {
            strArray[i] = "5";
        }
        else if (strArray[i] == "G")
        {
            strArray[i] = "6";
        }
        else if (strArray[i] == "H")
        {
            strArray[i] = "7";
        }
        else if (strArray[i] == "I")
        {
            strArray[i] = "8";
        }
        else
        {
            strArray[i] = "9";
        }
        str2 = str2 + strArray[i];
    }
    double num2 = Convert.ToDouble(str2) * 13567.0;
    this.textBox1.Text = Convert.ToString(num2).Substring(4, 8);
    this.textBox1.Visible = false;
}

希望得到讲解。
2015-12-14 23:07
boyving
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-11-28
得分:0 
这个运算我有点糊涂了,希望高人指点下。
2015-12-14 23:08
a646404908
Rank: 6Rank: 6
等 级:侠之大者
威 望:5
帖 子:189
专家分:492
注 册:2012-2-14
得分:20 
程序代码:
private void Freg_Load(object sender, EventArgs e)
{
    this.label2.Visible = false;
    this.Text1.Text = this.getCpu() + this.GetDiskVolumeSerialNumber();方法 getCpu()  GetDiskVolumeSerialNumber()返回值赋给text1
    //分割text1  Substring(2, 7)
    this.Text1.Text = this.Text1.Text.Substring(2, 7) + this.Text1.Text.Substring(15, 8);
    string text = "";
    text = this.Text1.Text;
    string[] strArray = new string[0x19];//长度19  string[] strArray = new string[19]
    string str2 = "";
    //然后就遍历呗。。
    for (int i = 5; i < 14; i++)
    {
        strArray[i] = text.Substring(i, 1);继续分割
        if (strArray[i] == "0")
        {
            strArray[i] = "0";
        }
        else if (strArray[i] == "1")
        {
            strArray[i] = "1";
        }
        else if (strArray[i] == "2")
        {
            strArray[i] = "2";
        }
        else if (strArray[i] == "3")
        {
            strArray[i] = "3";
        }
        else if (strArray[i] == "4")
        {
            strArray[i] = "4";
        }
        else if (strArray[i] == "5")
        {
            strArray[i] = "5";
        }
        else if (strArray[i] == "6")
        {
            strArray[i] = "6";
        }
        else if (strArray[i] == "7")
        {
            strArray[i] = "7";
        }
        else if (strArray[i] == "8")
        {
            strArray[i] = "8";
        }
        else if (strArray[i] == "9")
        {
            strArray[i] = "9";
        }
        else if (strArray[i] == "A")//从这里开始 是A就赋值0呗 以下的一样 前面的0-9其实可以删了。。
        {
            strArray[i] = "0";
        }
        else if (strArray[i] == "B")
        {
            strArray[i] = "1";
        }
        else if (strArray[i] == "C")
        {
            strArray[i] = "2";
        }
        else if (strArray[i] == "D")
        {
            strArray[i] = "3";
        }
        else if (strArray[i] == "E")
        {
            strArray[i] = "4";
        }
        else if (strArray[i] == "F")
        {
            strArray[i] = "5";
        }
        else if (strArray[i] == "G")
        {
            strArray[i] = "6";
        }
        else if (strArray[i] == "H")
        {
            strArray[i] = "7";
        }
        else if (strArray[i] == "I")
        {
            strArray[i] = "8";
        }
        else
        {
            strArray[i] = "9";
        }
        str2 = str2 + strArray[i];/拼接字符串
    }
    
    double num2 = Convert.ToDouble(str2) * 13567.0;
    this.textBox1.Text = Convert.ToString(num2).Substring(4, 8);
    this.textBox1.Visible = false;
}
没啥好说的。。。

2015-12-15 17:50
boyving
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-11-28
得分:0 
回复 3楼 a646404908
谢谢大神解答。。。虽然不够详细让我理解,不过也挺好了。。。呵呵!!我还是c#知识太薄弱不懂哦。
2015-12-15 21:48



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




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

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