# Suma 2.0

Using the Visual Studio integrated development environment and the C# programming language, we will develop a cross-platform mobile application to find the sum of two numbers.

## Start

1. Launch the Visual Studio integrated development environment.
2. Create a new project: **Visual C# > Cross-Platform > Mobile App (Xamarin.Forms)**.
3. Name the project: **Suma 2.0**.

## MainPage.xaml

The **MainPage.xaml** file contains the source code for the application's user interface design and is written in XAML. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.

```xml
<!-- User Interface (UI): Suma 2.0 -->
<StackLayout Padding="20">

        <!-- Title -->
        <Label Text="Suma 2.0" FontSize="Large" />

        <!-- A -->
        <Label Text="A=" />
        <Entry x:Name="boxA" Keyboard="Numeric" />

        <!-- B -->
        <Label Text="B=" />
        <Entry x:Name="boxB" Keyboard="Numeric" />

        <!-- A+B -->
        <Label Text="A+B=" />
        <Entry x:Name="boxAB" Keyboard="Numeric" />

        <!-- Button -->
        <Button Text="Sum" Clicked="OnButtonClicked" />

</StackLayout>
```

## MainPage.xaml.cs

The **MainPage.xaml.cs** file contains the source code for the application's business logic and is written in C#. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.

```csharp
// Business Logic (BL): Suma 2.0
public partial class MainPage : ContentPage
{
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        // Button Click Event Handler
        void OnButtonClicked(object sender, EventArgs args)
        {
            var A = int.Parse(this.boxA.Text);
            var B = int.Parse(this.boxB.Text);
            var C = A + B;
            boxAB.Text = C.ToString();
        }
}
```

## Demo

Run the application from the menu: **Debug > Start Debugging** or by pressing the **F5** key.

![](https://3608896458-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8MhIbAe4EayNL4gLUc2U%2Fuploads%2Fgit-blob-820dfba04d1d08df53c8698a7d9687d4ff1282cd%2F57_Suma_2.0.png?alt=media)

*Fig. 2.57 Testing the cross-platform mobile application for finding the sum of two numbers - Android Emulator 11 (API 30)*
