using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 性别选择练习
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
String A = "123的性别是" + Text;
if (radioButton1.Checked)
Text += ",男";
else
Text += ",女";
MessageBox.Show(A);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 性别选择练习
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
String A = "123的性别是" + Text;
if (radioButton1.Checked)
Text += ",男";
else
Text += ",女";
MessageBox.Show(A);
}
}
}
if (radioButton1.Checked)
Text += ",男";
else
Text += ",女";
String A = "123的性别是" + Text;
MessageBox.Show(A);
if (radioButton1.Checked)
A += ":男";
else
A += ":女";
MessageBox.Show(A);
一开始我也觉得Text变量没定义。不过一想,的确有个Form.Text,lz是歪打“歪”着
String A = "123的性别是" ;
if (radioButton1.Checked)
A += ",男";
else
A += ",女";
MessageBox.Show(A);