| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 625 人关注过本帖
标题:关于代码中的大规模替换
只看楼主 加入收藏
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
关于代码中的大规模替换
在编制大规模程序代码的时候,出现一些由于粗心大意导致的大小写问题
如下粉红色标记,如何实现快速实现CheckedListBoxPossibleValue替换为小写的checkedListBoxPossibleValue;


            InitializeComponent();
            // Add a tenth element to the CheckedListBox.
            this.CheckedListBoxPossibleValue.Items.Add("eleven");
        }

        private void Form1_Click(object sender, EventArgs e)
        {

        }

        private void buttonMove_Click(object sender, EventArgs e)
        {
            // Check if there are any checked items in the CheckedListBox.
            if (this.CheckedListBoxPossibleValue.CheckedItems.Count > 0)
            {
                // Clear the ListBox we'll move the selections to
                this.listBoxSelected.Items.Clear();

                // Loop through the CheckedItems collection of the CheckedListBox
                // and add the items in the Selected ListBox
                foreach (string item in this.CheckedListBoxPossibleValue.CheckedItems)
                {
                    this.listBoxSelected.Items.Add(item.ToString());
                }

                // Clear all the checks in the CheckedListBox
                for (int i = 0; i < this.checkedListBoxPossibleValue.Items.Count; i++)
                    this.checkedListBoxPossibleValue.SetItemChecked(i, false);
            }

        }
搜索更多相关主题的帖子: private void element 粉红色 
2013-05-16 15:50
lantian8134
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:8
帖 子:115
专家分:789
注 册:2013-1-11
收藏
得分:10 
鼠标右键CheckedListBoxPossibleValue->重构->重命名
2013-05-16 19:04
zml814994636
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2013-5-17
收藏
得分:10 
ctrl+f查找于替换..
2013-05-17 10:24
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
收藏
得分:0 
请问lantian8134版主 重构的具体用法 最好举个例子 谢谢

投之以桃,报之以李
2013-05-17 11:43
lantian8134
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:8
帖 子:115
专家分:789
注 册:2013-1-11
收藏
得分:0 
重构是指不改变已有的功能,对代码进行整理、优化等
如果有兴趣推荐看"重构-改善既有代码的设计"
程序代码:
class Class1
{
    public void Show()
    {
        string a=M1();
        string b=M2();
       
        Console.WriteLine(a+b);
    }
   
    private string M1()
    {
        return "你好 ";
    }
   
    private string M2()
    {
        return "世界";
    }
}

以下是重构之后的Show方法
public void Show()
    {
        //string a=M1();
        //string b=M2();
        //移除a,b两个临时变量
        Console.WriteLine(M1()+M2());
    }
是不是简单的有点不可思议?没错,其实这个就是重构的一种。
2013-05-22 09:53
快速回复:关于代码中的大规模替换
数据加载中...
 
   



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

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