界面设计
Label是最后显示xx年龄是xx岁的地方
代码区域
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 用桌面实现x的年龄是xx岁
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void button1_Click(object sender, EventArgs e)
{
int age;
string name;
string msg;//新定义的一个变亮,存储谁的年龄是多少岁
age=Convert.ToInt32(this.age.Text);
name = this.name.Text;
msg = String.Format("{0}的年龄是{1}岁", name, age);
lblMsg.Text = msg;//lblMsg.Text是label的name属性
MessageBox.Show(msg, "结果", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
//MessageBox.Show出现一个文本框,内容是后面括号里面的东西
}
}
}