1

Hi guys so am actually a novice in C# so i was working on a currency converter using WPF, the code is below after running the application i tried converting two currencies but it did not display the result please i need help with it.

    private void btn_Click(object sender, RoutedEventArgs e)
    {
        int conver;
        int i = int.Parse(amount_txt.Text);
        if (Combo1.SelectedItem == "US Dollar (USD)" && Combo2.SelectedItem == "Euro (EUR)")
        {
            conver = i * 87;
            display_txt.Content = "Converted Amount is : " + conver;
           
        }
        else if (Combo1.SelectedItem == "US Dollar (USD)" && Combo2.SelectedItem == "Pound Sterling (GPB)")
        {
            conver = i * 80;
            display_txt.Content = "Converted Amount is : " + conver;
        }
      
    }
clemon ezeh
  • 63
  • 2
  • 8
  • 2
    What is `display_txt`? If it's a `TextBox` then you should set the `Text` property, like `display_txt.Text = "Converted..."` – Sach Jul 14 '20 at 21:52
  • 1
    @sach Its a label – clemon ezeh Jul 14 '20 at 22:02
  • 1
    What happened when you debug this? Did the code go inside any of the two `if` statements? – Sach Jul 14 '20 at 22:05
  • 1
    @Sach No at all it displayed the desktop app so when i Clicked the button to convert the 2 currencies it didn't display the output of the conversion – clemon ezeh Jul 14 '20 at 22:10
  • 1
    So you should debug your application. https://learn.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?toc=%2Fvisualstudio%2Fdebugger%2Ftoc.json&view=vs-2019 – Sach Jul 14 '20 at 22:14
  • 1
    @Sach after debugging my application I clicked the combo box for Dollars and Euro then I clicked the convert button it didn't display the result of the conversion – clemon ezeh Jul 14 '20 at 22:34
  • 1
    Please read the linked article properly. You need to add breakpoints, and step through your code using debugger to see what happens in your code at each step. I understand you don't get the final result, but the way to figure out why you don't get it is to debug and go through the code step by step. – Sach Jul 14 '20 at 22:40
  • 1
    @Sach Thank you so much – clemon ezeh Jul 14 '20 at 22:58
  • Is there any update for your issue?There is also a Microsoft document [First look at the Visual Studio Debugger](https://learn.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019) for you to refer. – DasiyTian_1203 Aug 06 '20 at 06:31

0 Answers0