Classes

Simon4VB

Member
Joined
Apr 2, 2009
Messages
23
Programming Experience
1-3
May I ask how to solve this question please.

Public Class Class1
Public mSize As Integer
End Class
1) How to define another method inside the Class1 that allows other programs to retreive the value of mSize

and

2) How to disallow client programs from directly accessing mSize.

Thanks in advance.
 

Satal Keto

Well-known member
Joined
May 15, 2006
Messages
86
Programming Experience
5-10
I would suggest that you have a quick read of this webpage;
Understanding Properties in VB.NET
Although to give you a brief understanding to have a method inside of the class to give you access to mSize you could do this;
Code:
Public Function getSize() As Integer
    Return mSize
End Function
Although to be honest I would actually recommend using a Property instead of a method as that is what they're there for, so instead you could use;
Code:
Public Property Size() As Integer
    Get
        Return mSize
    End Get
    Set(ByVal Value As Integer)
        mSize = Value
    End Set
End Property
As for the second part, I would suggest that you have a read of this;
DotNetBips.com :: Blossom your .NET skills

Anyway I hope that this helps

Satal :D
 
Top Bottom