本文介绍了为什么我可以访问同一班级的任何私人课程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Module Module1
    Sub Main()
        Dim oMyTest As New MyTest

        oMyTest.CreateMyName("Call From OutSide, Why Can't I assign directly to MyName")
       'oMyTest.MyName = ("Why Can’t I DO THIS")
    End Sub

End Module

Public Class MyTest

    Private MyName As String

    Public Sub CreateMyName(ByVal sString As String)
        MyName = sString
        Console.WriteLine(MyName)

        Dim oMyTest As New MyTest

       ' oMyTest.MyName = "Why does this work"
' why does this work 
' if I initiate a the same class object inside the same class i can access all private fields, function, and methods.
        Console.WriteLine(MyName)
        Console.WriteLine("Inside Obect: " & oMyTest.MyName)
    End Sub
End Class

推荐答案



这篇关于为什么我可以访问同一班级的任何私人课程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 21:59