I'm totally new to .NET and I'm trying to get to know C# by running the codes I encounter in the books I follow..
I'm building a simple WPF app with a button, which should print out the hypoteneuse. My question is; In the bellow code example from the book, there is these two namespaces (Syncfusion and NamespaceDemo). Do I have to include them both? What is a better way to use these code? Secondly, When creating a new WPF file and a button for the application, it automatically generates this piece of code:
 public MainWindow()
        {
            InitializeComponent();
        }
I know that the MainWindow() is for the design that will include the button. How does it differs from the Main() function in a simple C# console application? I would appreciate a clear explaination about my confusion with how this different things has to be structured properly. Do I need a Main()?
This is the code from book:
using static System.Math; 
namespace Syncfusion  
{ 
public class Calc 
{ 
public static double Pythagorean(double a, double b) 
{ double cSquared = Pow(a, 2) + Pow(b, 2); 
return Sqrt(cSquared); } 
} 
}
using Syncfusion; 
using System; 
using Crypto = System.Security.Cryptography; 
namespace NamespaceDemo 
{ 
class Program 
{ 
static void Main() 
{ 
double hypotenuse = Calc.Pythagorean(2, 3); 
Console.WriteLine("Hypotenuse: " + hypotenuse); 
Crypto.AesManaged aes = new Crypto.AesManaged(); 
Console.ReadKey();
 } 
} 
}
This is my implementation, which unfortunately doesn't work.
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;
using static System.Math;
namespace Syncfusion
{
    public class Calc
    {
        public static double Pythagorean(double a, double b)
        {
            double cSquared = Pow(a, 2) + Pow(b, 3);
            return Sqrt(cSquared);
        }
    }
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        void Button_Click(object sender, RoutedEventArgs e)
        {
            double hypotenuse = Calc.Pythagorean(2, 4);
            MessageBox.Show("Hypotenuse: " + hypotenuse);
        }
    }
}
