字符替換

 private void copyClick(object sender, RoutedEventArgs e)
        {
            target.Text = "";
            string from = source.Text;
            for (int i = 0; i != from.Length; i++)
            {
                char current = from[i];
                copyOne(current);
            }
        }


        private void copyOne(char current)
        {
            switch (current)
            {
                case '>':
                    target.Text += ">";
                    break;
                case '<':
                    target.Text += "&lt;";
                    break;
                case '\"':
                    target.Text += "&#34;";
                    break;
                default:
                    target.Text += current;
                    break;
            }
發佈了28 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章