문제

Hi am quite new to visual studios.

This is my code so far to make an example of an atm, where you the put the amount in and then click credit it adds to the balance and click debit and it takes it out. am doing this inc# wpf application.

so far i have this.

public MainWindow()
        {
            InitializeComponent();
        }

    private double totalamount = 0;
    public string balance1;


    private void buttoncredit_Click(object sender, RoutedEventArgs e)
    {
        totalamount = totalamount + double.Parse(textboxamount.Text);

        balance1 = "Your Balance is: £";

        label2 = balance1 + totalamount;

and then this error comes along . "Cannot implicitly convert type 'string' to 'System.Windows.Controls.Label"

I have done this in forms . where i say label2.text = ..... and it works . but on the wpf i can't do this. if someone can guide me it will be much appricated.

thanks .

도움이 되었습니까?

해결책

For wpf the equivalent is:

label2.Content = balance1 + totalamount;

다른 팁

You want to set the Text property of the Label not the Label itself. So try this:

In Windows form:

label2.Text = balance1 + totalamount;

In WPF:

label2.Content = balance1 + totalamount;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top