using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace Example35

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void Form1_Shown(object sender, EventArgs e)

        {

            this.Text = "将字母全部转换为大写或小写";

        }

        private void button1_Click(object sender, EventArgs e)

        {

            if (radioButton1.Checked)

            {

                textBox2.Text = textBox1.Text.ToUpper();  //转换为 大写 

            }

            if (radioButton2.Checked)

            {

                textBox2.Text = textBox1.Text.ToLower();  //转换为 小写

            }

        }

    }

}

//字符串是 不可变 对象 每当对字符串进行操作时 都将产生一个新的字符串对象 尽量避免频繁操作字符串对象 因为频繁操作会在托管堆中产生大量的无用字符串 增加垃圾收集器的压力 从而造成系统资源的浪费!
posted on 2011-10-18 20:32  C#_初学者  阅读(803)  评论(0编辑  收藏  举报