简体   繁体   中英

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#.

您可以构建PCL或使用代码共享构建特定于平台的库。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM