Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin shared code between iOS, Android and Core project

I'm new to Xamarin and made two interfaces for Android and iOS. I have one Core project and put references in the Android and iOS project to the Core project.

How can I use code from my Core project in my iOS/Android project?

For example, this is my Core class TestClass.cs:

using System;
using System.Threading.Tasks;

namespace FindMyRide.Core
{
    public class TestClass
    {

        public string TestString { get; set; }

        public TestClass ()
        {
            TestString = "Hallo";
        }
    }
}

How can I display the TestString in my iOS or Android application?

I don't know if this is the correct use of shared coding in Xamarin, as I said I'm very new to this and to C#.

like image 961
Tom Spee Avatar asked May 08 '26 14:05

Tom Spee


1 Answers

You could either build a PCL or build platform specific libraries with code sharing.

like image 196
SKall Avatar answered May 11 '26 04:05

SKall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!