为什么它计算一些数字正确而一些数字错误? C#

Why does it Calculate some numbers right and some numbers wrong? C#

我猜我的计算器有错误,有时计算正确,有时计算错误。我想做一个 U-R-I 计算器,从 U = R * I 开始。

wrong calc:

Right calc:

我是 c# 的新手,在对 wpf 进行控制台编程 3 个月后才开始。 这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace URI_CALC
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    double test_1;
    string s_test1;
    double test_2;
    string s_test2;
    double result;
    string s_result;

    private void textbox_test_TextChanged(object sender, TextChangedEventArgs e)
    {
        s_test1 = textbox_test.Text;
    }

    private void Button_Calc_GETU_Click(object sender, RoutedEventArgs e)
    {
        test_1 = Convert.ToDouble(s_test1);
        test_2 = Convert.ToDouble(s_test2);
        result = (test_1 * test_2);
        s_result = Convert.ToString(result);
        textblock_u.Text = s_result;
    }

    private void TestTextbox2_TextChanged(object sender, TextChangedEventArgs e)
    {
        s_test2 = textbox_test.Text;
    }



   }
   }

你有bug,这两个是一样的

private void textbox_test_TextChanged(object sender, TextChangedEventArgs e)
{
    s_test1 = textbox_test.Text;
}

  
private void TestTextbox2_TextChanged(object sender, TextChangedEventArgs e)
{
    s_test2 = textbox_test.Text;
}

修复文本框的名称,它们应该不同