109,901
社区成员




private void button1_Click(object sender, EventArgs e)
{
//用于存储最长的长度
int MaxL = 0;
string[] strList = new string[] { "检查网络连接", "检查系统完整性", "检查服务器当前状态" };
//循环取最长的长度(此循环待改善)
for (int i = 0; i < strList.Length; i++)
{
try
{
if (strList[i].Length > strList[i + 1].Length)
{
MaxL = strList[i].Length;
}
else
{
MaxL = strList[i + 1].Length;
}
}catch { }
}
//循环增加固定的空格
foreach (string str in strList)
{
string space = "";
//此处的‘5’可以控制OK到前面的字符之间的距离
for (int i = 0; i < MaxL - str.Length + 5; i++)
{
space += " ";
}
textBox1.Text += "\r\n" + str + space + "OK";
}
}
void Main()
{
string a = "AAAAA";
string b = "测试字符串";
string c = "For测试";
richTextBox1.Text = "";
BQ(a);
BQ(b);
BQ(c);
}
void BQ(string str)
{
richTextBox1.Text += str;
foreach (char l in str)
{
Regex rex = new Regex("[a-z0-9A-Z_]+");
Match ma = rex.Match(l.ToString());
if (ma.Success)
{
richTextBox1.Text += " ";
}
}
richTextBox1.Text += " "+str.Length + "\n";
}