| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2552 人关注过本帖
标题:求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
快速回复:求C#段代码表达意思
数据加载中...
 
   



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

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