プログラミングは全く新しいです。私は現在、number1の平方根などを計算するWPF Appを作成しようとしています。私は平方根を計算するメソッドを使うことに問題があります。MainWindowの必要な仮パラメータ 'sender'に対応する引数はありません。
が必要な仮パラメータ「差出人」「MainWindow.RadioBT_Root2_Checked(オブジェクト、RoutedEventArgs)」
このエラーはRadioBT_Root3_Checkedとで発生に対応して与えられた引数がありません:私は言ってエラーを得ました私は3つの方法があるので、RadioBT_Root4_Checked。
コードはCS7036です。何が悪いの?私はそんなに捜していましたが、私はそれを見つけることができません(または私は検索できません)。
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 Examples {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow: Window {
public MainWindow() {
InitializeComponent();
}
double number1;
double number2;
double result;
private void TXB_1_TextChanged(object sender, TextChangedEventArgs e) {
}
private void TXB_2_TextChanged(object sender, TextChangedEventArgs e) {
}
private void BT_Potegowanie_Click(object sender, RoutedEventArgs e) {
try {
number1 = double.Parse(TXB_1.Text);
number2 = double.Parse(TXB_2.Text);
result = Math.Pow(number1, number2);
MessageBox.Show("WYNIK: " + result.ToString());
} catch (Exception) {
MessageBox.Show("Wystąpił błąd.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public void BT_Root_Click(object sender, RoutedEventArgs e) {
if (RadioBT_Root2_Checked()) ///CS7036
MessageBox.Show("RESULT: " + result.ToString());
if (RadioBT_Root3_Checked()) ///CS7036
MessageBox.Show("RESULT: " + result.ToString());
if (RadioBT_Root4_Checked()) ///CS7036
MessageBox.Show("RESULT: " + result.ToString());
}
public void RadioBT_Root2_Checked(object sender, RoutedEventArgs e) {
number1 = double.Parse(TXB_1.Text);
result = Math.Sqrt(number1);
}
public void RadioBT_Root3_Checked(object sender, RoutedEventArgs e) {
number1 = double.Parse(TXB_1.Text);
number2 = (1/3.0);
result = Math.Pow(number1, number2);
}
public void RadioBT_Root4_Checked(object sender, RoutedEventArgs e) {
number1 = double.Parse(TXB_1.Text);
number2 = (1/4.0);
result = Math.Pow(number1, number2);
}
}
}
EDIT:私はEd Plunkettが解決したことを実行しました。私は今もう別の問題を抱えています。それはXAML関連です(私は思う)。私はまた、私は場所が必要かもしれないことがわかった??ある場所では「偽」です。 'MainWindow'に 'RadioBT_Root4_Checked'の定義が含まれておらず、 'MainWindow'タイプの最初の引数を受け入れる拡張メソッド 'RadioBT_Root4_Checked'が見つかりませんでした(usingディレクティブまたはアセンブリ参照がありません)
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 Examples
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TXB_1_TextChanged(object sender, TextChan`enter code here`gedEventArgs e)
{
}
private void TXB_2_TextChanged(object sender, TextChangedEventArgs e)
{
}
public void BT_Root_Click(object sender, RoutedEventArgs e)
{
double number1 = 0;
double number2 = 0;
double result = 0;
if (RadioBT_Root2.IsChecked ?? false) ///CS0266
{
number1 = double.Parse(TXB_1.Text);
result = Math.Sqrt(number1);
}
else if (RadioBT_Root3.IsChecked ?? false) ///CS0266
{
number1 = double.Parse(TXB_1.Text);
number2 = (1/3.0);
result = Math.Pow(number1, number2);
}
else if (RadioBT_Root4.IsChecked ?? false) ///CS0266
{
number1 = double.Parse(TXB_1.Text);
number2 = (1/4.0);
result = Math.Pow(number1, number2);
}
MessageBox.Show("RESULT: " + result.ToString());
}
}
私のXAMLコード:
<Window x:Class="Examples.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Examples"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Label x:Name="label" Content="First number

First number" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" Width="117" Height="31" FontSize="15"/>
<TextBox x:Name="TXB_1" HorizontalAlignment="Left" Height="28" Margin="132,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" FontSize="15" TextChanged="TXB_1_TextChanged"/>
<Label x:Name="label1" Content="Second number

Second number
" HorizontalAlignment="Left" Margin="10,46,0,0" VerticalAlignment="Top" Width="117" Height="30" FontSize="15"/>
<TextBox x:Name="TXB_2" HorizontalAlignment="Left" Height="28" Margin="132,48,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" TextChanged="TXB_2_TextChanged" FontSize="15"/>
<Separator HorizontalAlignment="Left" Height="19" Margin="0,69,0,0" VerticalAlignment="Top" Width="517"/>
<Button x:Name="BT_Root" Content="ROOT" HorizontalAlignment="Left" Margin="10,81,0,0" VerticalAlignment="Top" Width="128" Height="48" FontSize="16" Click="BT_Root_Click"/>
<RadioButton x:Name="RadioBT_Root2" Content="Root2" HorizontalAlignment="Left" Margin="143,81,0,0" VerticalAlignment="Top" Checked="RadioBT_Root2_Checked"/>
<RadioButton x:Name="RadioBT_Root3" Content="Root3" HorizontalAlignment="Left" Margin="143,96,0,0" VerticalAlignment="Top" Checked="RadioBT_Root3_Checked"/>
<RadioButton x:Name="RadioBT_Root4" Content="Root4" HorizontalAlignment="Left" Margin="143,111,0,0" VerticalAlignment="Top" Checked="RadioBT_Root4_Checked"/>
</Grid>
</Window>
を私は '= "RadioBT_Root4.IsChecked" />チェック' に '= "RadioBT_Root4_Checked" />チェック' 変更しようとしたaslo。 'Error Checked = "RadioBT_Root2.IsChecked"は無効です。 'RadioBT_Root2.IsChecked'は有効なイベントハンドラメソッド名ではありません。生成クラスまたはコードビハインドクラスのインスタンスメソッドのみが有効です。 '
XAMLも投稿してください –
ここでやめて、まずC#のプログラミングに関する書籍を読んで理解してください。 – Clemens