Do you declare member accessibility for all classes?

Updated by Brady Stroud [SSW] 1 year ago. See history

123

Not explicitly specifying the access type for members of a structure or class can be misleading for other developers. The default member accessibility level for classes and structs in Visual C# .NET is always private. In Visual Basic .NET, the default for classes is private, but for structs is public.

Match MatchExpression(string input, string pattern)

❌ Figure: Figure: Bad - Method without member accessibility declared

private Match MatchExpression(string input, string pattern)

✅ Figure: Figure: Good - Method with member accessibility declared

Image

Figure: Compiler warning given for not explicitly defining member access level

We have a program called SSW Code Auditor to check for this rule.

acknowledgements
related rules