我有这个代码用于找到Textbox1最伟大的Textbox2 代码工作,但如果我使“0”或“0,5”有一个错误(如果有“,”)。
任何人都有接受“0”或“,”的解决方案?
public partial class MainWindow : Window
{
int point1, point2;
int point3, point4;
public MainWindow()
{
InitializeComponent();
point1 = point2 = 0;
point3 = point4 = 0;
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox1.Text != "") {
point1 = int.Parse(textBox1.Text);
int tt;
int uu;
tt = point1 - point2;
uu = point3 - point4;
if (tt >=uu)
texboxxol1.Background = Brushes.Yellow;
texboxxol2.Background = Brushes.White;
}
}
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox2.Text != "")
{
point2 = int.Parse(textBox2.Text);
int tt;
int uu;
tt = point1 - point2;
uu = point2 - point1;
if (uu >= tt)
texboxxol2.Background = Brushes.White;
texboxxol1.Background = Brushes.Yellow;
}
}
答案 0 :(得分:1)