定长数字,不足位数前边补0

来源:互联网 发布:sql默认地址不详设置 编辑:程序博客网 时间:2024/04/27 04:44
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 ChangeNumberLength{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            int number = textBox1.Text.Length;            for (;number < 10;number++)            {                textBox1.Text = "0" + textBox1.Text;            }            MessageBox.Show("Change number is" + textBox1.Text,"Tips",MessageBoxButtons.YesNo);        }    }}