共用方式為


箭頭運算式子句權杖 (IDE2006) 之後不允許空白行

房產 價值觀
規則識別碼 IDE2006
標題 箭頭運算式子句記號後不允許空白行
類別 Style
子類別 語言規則 (換行偏好設定)
適用語言 C#
Options csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental

備註

此規則是實驗性的,可能會變更或刪除。

概觀

此樣式規則會強制表示式主體成員、Lambda 運算式或 switch 運算式中的箭頭 (=>) 記號後面不應有空行。 運算式應緊接在箭頭後面,沒有任何空行。

選項

選項指定您希望規則強制執行的行為。 如需設定選項的相關資訊,請參閱 選項格式

csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental

房產 價值觀 Description
選項名稱 csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental
選項值 true 允許箭頭運算式子句中的記號後面有空行
false 要求運算式緊接在箭頭運算式子句中的權杖後面
預設選項值 true

Example

// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
public int Method() =>
    9 + 1;
// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
public int Method()
    => 9 + 1;

隱藏警告

如果您只想隱藏單一違規,請將前置處理器指示詞新增至來源檔案以停用,然後重新啟用規則。

#pragma warning disable IDE2006
// The code that's violating the rule is on this line.
#pragma warning restore IDE2006

若要停用檔案、資料夾或專案的規則,請在組態檔中將其嚴重性設定為 。none

[*.{cs,vb}]
dotnet_diagnostic.IDE2006.severity = none

若要停用所有程式碼樣式規則,請在組態檔中將類別Style的嚴重性設定為。none

[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none

如需詳細資訊,請參閱 如何隱藏程式碼分析警告

另請參閱