In NET 6, to handle different platforms is to use conditional compilation statements

當前文章的短網址連結為: https://unos.top/fbdu

There are four preprocessor directives that control conditional compilation:

#if, #elif, #else, and #endif.Code language: CSS (css)

You define symbols using #define, as shown in the following code:

#define MYSYMBOL

Many symbols are automatically defined for you, as shown in the following table:

Target FrameworkSymbols
.NET StandardNETSTANDARD2_0, NETSTANDARD2_1, and so on
Modern .NETNET6_0, NET6_0_ANDROID, NET6_0_IOS, NET6_0_WINDOWS, and so on

You can then write statements that will compile only for the specified platforms, as shown in the following code:

#if NET6_0_ANDROID
// compile statements that only works on Android
#elif NET6_0_IOS
// compile statements that only works on iOS
#else
// compile statements that work everywhere else
#endif
5 1 投票
文章评分
订阅评论
提醒
guest

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

0 评论
内联反馈
查看所有评论