如何讓首字母變成大小寫

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;

// 吳新強於2013年4月10日 桂電 2507
namespace ReplaceWord
{
    public partial class Frm_Main : Form
    {
        public Frm_Main()
        {
            InitializeComponent();
        }


        private void Frm_Main_Load(object sender, EventArgs e)
        {


        }
        /// <summary>
        /// 首字母轉換成大寫
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butup_Click(object sender, EventArgs e)
        {
            string str1 = textBox1.Text.Substring(0, 1);
            string str2 = textBox1.Text.Substring(1, textBox1.Text.Length - 1);
            label3.Text = str1.ToUpper() + str2;
        }
        /// <summary>
        /// 首字母轉換成小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butlow_Click(object sender, EventArgs e)
        {
            string str1 = textBox1.Text.Substring(0, 1);
            string str2 = textBox1.Text.Substring(1, textBox1.Text.Length - 1);
            label3.Text = str1.ToLower() + str2;


        }
    }

}

實驗結果:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章