次の方法で共有


CA1504: Review misleading field names

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Item Value
RuleId CA1504
Category Microsoft.Maintainability
Breaking change Non-breaking

Cause

The name of an instance field starts with "s_" or the name of a static (Shared in Visual Basic) field starts with "m_".

Note

This rule has been deprecated. For more information, see Deprecated rules.

Rule description

Field names that start with "s_" are associated with static data by many users. Similarly, field names that start with "m_" are associated with instance (member) data. For more easily maintained code, names should follow generally used conventions.

How to fix violations

To fix a violation of this rule, rename the field by using the appropriate prefix. Alternatively, make the field agree with the current suffix by adding or removing the static modifier.

When to suppress warnings

Do not suppress a warning from this rule.