Do you declare member accessibility for all classes?

Loading last updated info...

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.

Categories

Authors

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star