在用C#之间调用类时如下:
【C#】
class Class1
{
private string _strName;
public string StrName
{
get { return _strName; }
set { _strName = value; }
}
}
class Class2
{
public String GetClass1Property()
{
Class1 c1 = new Class1();
c1.StrName="A";
return c1.StrName;
}
}
但是在VB.NET中进行上如仿造练习是频频出错的。个人实验后正确代码如下(或许还有其他方式)
【VB.NET】
Public Class test1
Private _strNum As String
Public Property StrNum As String
Get
Return _strNum
End Get
Set(ByVal value As String)
_strNum = value
End Set
End Property
Property Orders As New List(Of String) From {"A","B","C"}
End Class
----------------------------------
Public Class test2
Public Sub ClassGet()
Dim t1 As New test1
t1.StrNum = "a"
End Sub
Public Function ClassGetFunction() As String
Dim t2 As New test1
t2.StrNum = "B"
Return t2.StrNum
End Function
End Class