- Xamarin Blueprints
- Michael Williams
- 186字
- 2021-07-08 11:48:19
Shared projects
We are going to delve into our first technique for sharing code between different platforms. This is what Xamarin wants us to achieve, and reuse as much code as possible. The biggest disadvantage when developing natively is two different language, and we can't reuse anything.
Let's create our first shared project:

Our shared project will be used to contain the GalleryItem
model, so whatever code we include in this shared project can be accessed by both the iOS and Android projects:

In the preceding screenshot, have a look at the Solution explorer, and notice how the shared project doesn't contain anything more than .cs
code sheets. Shared projects do not have any references or components, just code that is shared by all platform projects. When our native projects reference these shared projects, any libraries being referenced via using
statements come from the native projects.
Now we must have the iOS and Android projects reference the shared project; right-click on the References folder and select Edit References:

Select the shared project you just created and we can now reference the GalleryItem
object from both projects.
- DevOps:軟件架構(gòu)師行動(dòng)指南
- Redis Applied Design Patterns
- 大學(xué)計(jì)算機(jī)基礎(chǔ)實(shí)驗(yàn)教程
- JavaFX Essentials
- Hands-On Data Structures and Algorithms with JavaScript
- JS全書:JavaScript Web前端開發(fā)指南
- Hands-On GPU:Accelerated Computer Vision with OpenCV and CUDA
- Learning Apache Mahout Classification
- C# 8.0核心技術(shù)指南(原書第8版)
- SQL Server實(shí)用教程(SQL Server 2008版)
- Python3.5從零開始學(xué)
- Emgu CV Essentials
- Spring Boot+MVC實(shí)戰(zhàn)指南
- Developing SSRS Reports for Dynamics AX
- 快樂(lè)編程:青少年思維訓(xùn)練