Does Xamarin have an #if or #ifdef for determining the platform?

cross-platform, xamarin

Solution

iOS:

#if __MOBILE__
    Console.WriteLine ("__MOBILE__ is defined");
#endif 

#if __IOS__
    Console.WriteLine ("__IOS__ is defined");
#endif 

Android:

#if __MOBILE__
    Console.WriteLine ("__MOBILE__ is defined");
#endif 

#if __ANDROID__
    Console.WriteLine ("__ANDROID__ is defined");
#endif

https://bugzilla.xamarin.com/show_bug.cgi?id=6459#c12

xamarin documentation

Problem

For example, #ifdef iOS, #ifdef android, or the like. If there is #if, that would be even better.

Original source