P
PMK
Hi,
I'm trying to translate this little tutorial from C# to VB but am
going wrong somewhere.
I create a simple custom class in customer.vb
Public Class Customer
Private m_age As Integer
Private m_name As String
Private Property Age() As Integer
Get
Return m_age
End Get
Set(ByVal value As Integer)
m_age = value
End Set
End Property
Private Property Name() As String
Get
Return m_name
End Get
Set(ByVal value As String)
m_name = value
End Set
End Property
'NOT SURE I HAVE WRITTEN THE METHOD CORRECTLY OR NOT
'THE C# SAMPLE USES THE SAME NAME 'CUSTOMER' FOR THE METHOD SO THAT IS
WHAT I DID (ALSO TRIED OTHER NAMES)
Public Sub Customer(ByVal pName As String, ByVal pAge As Integer)
m_age = pAge
m_name = pName
End Sub
End Class
Then in another class, the C# code is:
public class SalesPersonCustomers
{
private List<Customer> _salesCustomers;
public SalesPersonCustomers()
{
_salesCustomers = new List<Customer>();
_salesCustomers.Add(new Customer("Alice", 10));
}
public List<Customer> GetCustomers(string _salesName)
{
return _salesCustomers;
}
}
What i tried (and variations) in VB is:
Dim _salesCustomers as List(of Customer)
Sub SalesPersonCustomers()
_salesCustomers = New List(Of Customer)
_salesCustomers.Add(Customer
End Sub
But I don't get the prompt on the _salesCustomers.Add(Customer line
for the parameters of name and age so the records are not added.
Thanks,
Peter
I'm trying to translate this little tutorial from C# to VB but am
going wrong somewhere.
I create a simple custom class in customer.vb
Public Class Customer
Private m_age As Integer
Private m_name As String
Private Property Age() As Integer
Get
Return m_age
End Get
Set(ByVal value As Integer)
m_age = value
End Set
End Property
Private Property Name() As String
Get
Return m_name
End Get
Set(ByVal value As String)
m_name = value
End Set
End Property
'NOT SURE I HAVE WRITTEN THE METHOD CORRECTLY OR NOT
'THE C# SAMPLE USES THE SAME NAME 'CUSTOMER' FOR THE METHOD SO THAT IS
WHAT I DID (ALSO TRIED OTHER NAMES)
Public Sub Customer(ByVal pName As String, ByVal pAge As Integer)
m_age = pAge
m_name = pName
End Sub
End Class
Then in another class, the C# code is:
public class SalesPersonCustomers
{
private List<Customer> _salesCustomers;
public SalesPersonCustomers()
{
_salesCustomers = new List<Customer>();
_salesCustomers.Add(new Customer("Alice", 10));
}
public List<Customer> GetCustomers(string _salesName)
{
return _salesCustomers;
}
}
What i tried (and variations) in VB is:
Dim _salesCustomers as List(of Customer)
Sub SalesPersonCustomers()
_salesCustomers = New List(Of Customer)
_salesCustomers.Add(Customer
End Sub
But I don't get the prompt on the _salesCustomers.Add(Customer line
for the parameters of name and age so the records are not added.
Thanks,
Peter