【发布时间】:2021-10-13 19:13:11
【问题描述】:
我猜我的计算器有错误,有时计算正确,有时计算错误。我想做一个 U-R-I 计算器,从 U = R * I 开始。
我对 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;
}
}
}
【问题讨论】:
-
卑微的请求,请更改您的应用背景
标签: c# string wpf double calculator