There are three ways we can share code:
- Shared Project: Here, if required, we write platform specific code using
#if
compiler directives. - Portable Class Libraries: Here, we create a PCL targeting the platforms we wish to support and then we use Interfaces & Dependency Services to use platform specific functionality.
- .NET Standard Libraries: It works similar to the PCL and requires Interfaces to work with platform specific functionality.