• Add Classes to Xamarin Android PCL Project with Visual Studio and C# in Sample MyBookStore App

    by  • December 6, 2016 • Android with C# and .NET, Xamarin Mobile App Development • 1 Comment

    In the previous post, we setup a solution along with two projects for our Xamarin Android App. That was a starting point for creating our Android App with .NET, Visual Studio and C#. The structure looked similar to any other .NET solution. In this post, I’ll show you the code which we’ll be adding in the Portable Code Library (PCL) project named MyBookStore.Core.

    In the below screenshot, you can see how these two classes will look like in the solution.


    Now, let’s see how the code in these four classes look like. The first two classes Book and Category are model classes which will just model our data and objects to pass along from different layers. The BookRepository class will fetch the data and fill these model objects. And the BookService will act as a service to provide data to the consumer, like the Android project in our Xamarin solution.

    Model Classes with Code

    The Book model class.

    The Category Model class.

    Repository Class

    In this project, we’re fetching dummy data which we have added in the repository class. In the future projects, we’ll fetch data from a database or a service.

    Service Class

    You can add the above code in your Core (PCL) project. In the future posts, I’ll explain how to work with the Android project in our solution and how to link the MyBookStore.Core library to the Android project. If you have any problem understanding the concepts or code shared in this post, please leave a comment and I’ll answer your questions.

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of admin


    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    One Response to Add Classes to Xamarin Android PCL Project with Visual Studio and C# in Sample MyBookStore App

    1. Ankit
      May 3, 2017 at 7:31 pm

      Best Site ever . Thanks a lot . If you were here , I would have given you tight Hug for this help .

    Leave a Reply