[英]Can you add a preprocessor directive for a C# version?
有沒有辦法添加一個預處理器指令來比較編譯器使用的 C# 版本?
例如 :
public T MyMethod<T>()
{
#if CS_7
return default; // Feature 'default literal' is not available in C# 7.0. Please use 7.1 or greater.
#else
return null; // Ignore the fact that this won't work, it isn't the point of the question
#endif
}
.NET 版本是通往這里的路嗎? 不會有同一個項目使用的編譯器不同的情況嗎? (即如果不同的員工使用不同版本的 Visual Studio)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.