Sharing code with other platforms

One of the major reasons for using Xamarin.Android is the use of C# as the programming language. But this is not the only benefit as that same C# code can be shared with other platforms, such as iOS, Windows, or Mac OS.

How to do it...

First, we are going to create the project structure that we are going to use to create our cross-platform app. In this example, we will only target Xamarin.Android and the Console, but extra platforms can be added.

  1. Open Xamarin Studio or Visual Studio and create an empty solution. For example, we are going to call this one XamarinCodeSharing.
  2. In this solution, create three projects:
    • An Android project named XamarinCodeSharing.Droid
    • A console application named XamarinCodeSharing.Desktop ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.