CA1034: Nested types should not be visible

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-05-04T05:39:41Z Indexed on 2010/05/04 5:48 UTC
Read the original article Hit count: 488

Filed under:
|
|

Here's an explanation of the rule that that I am trying to understand. Here's the simplified code that the Code Analyzer was complaining about:

Public Class CustomerSpeed

    Public Enum ProfitTypeEnum As Integer
        NotSpecified = 0
        FlatAmount = 1
        PercentOfProfit = 2
    End Enum

    Private _ProfitTypeEnum As ProfitTypeEnum

    Public Sub New(ByVal profitType As ProfitTypeEnum)

        _ProfitTypeEnum = profitType

    End Sub

End Class

If the enum pertains only to the class, why is it a bad thing to make it a contained type within the class? Seems neater to me...

Does anyone know what is meant by the following line?:

Nested types include the notion of member accessibility, which some programmers do not understand clearly

Using Namespaces to group the Class and Enum doesn't seem like a useful way to resolve this warning, since I would like both the enum to belong to the same parent level as the class name.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about .NET