maj*_*m84 2 c# string-formatting
字符串格式在命令行中格式正常,但在带有标签的gui中它完全关闭.我认为我的格式是正确的
例:
码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DisplayMultiplicationTableGUI
{
public partial class Form1 : Form
{
int i, j;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = String.Format("{0,3}", " ");
for (i = 1; i <= 10; i++)
label1.Text += String.Format(" {0,3}", (i).ToString());
for (i = 1; i <= 10; i++)
label2.Text += String.Format("\n{0,3} ", (i).ToString());
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 10; j++)
label3.Text += String.Format("{0,3} ", (i*j).ToString());
label3.Text += String.Format("\n");
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
171 次 |
最近记录: |