Is it possible to get namespace functionality inside a class?

I have the following code:

Public Class Form1
Private Function Step1_Execute() As Boolean
    Return Step1_Verify()
End Function

Private Function Step1_Verify() As Boolean
    Return True
End Function

Private Function Step2_Execute() As Boolean
    Return Step2_Verify()
End Function

Private Function Step2_Verify() As Boolean
    Return True
End Function
End Class

What I would like to do is split the code similar to the following (which obviously doesn't work):

Public Class Form1

Namespace Step1
    Private Function Step1_Execute() As Boolean
        Return Step1_Verify()
    End Function

    Private Function Step1_Verify() As Boolean
        Return True
    End Function
End Namespace

Namespace Step2
    Private Function Step2_Execute() As Boolean
        Return Step2_Verify()
    End Function

    Private Function Step2_Verify() As Boolean
        Return True
    End Function
End Namespace

End Class

I need the functionality of namespaces inside the class, as in that would allow me to call Step2.Execute () instead of putting Step2_ in front of a whole set of functions. I do not want to create separate classes / modules for step1, step2, etc.

Is there a way I can implement namespace functionality inside a class?

+3
source share
3 answers

module ( #)? , , .

Module Step1
    Private Function Execute() As Boolean
        Return Verify()
    End Function

    Private Function Verify() As Boolean
        Return True
    End Function
End Module

Module Step2
    Private Function Execute() As Boolean
        Return Step2_Verify()
    End Function

    Private Function Verify() As Boolean
        Return True
    End Function
End Module

, VB.NET Module , .

Edit:

, ( ), . , , , .

+2

.

. - . , System.Text.StringBuilder, "using System.Text" " , , " System.Text ' .

+1

, 3 . , . 2, execute verify .

wil , , .

+1

Source: https://habr.com/ru/post/1743645/


All Articles