Override the method toString()

  • Thread starter Thread starter portroe
  • Start date Start date
P

portroe

How Do i override the method toString()?

Now it should return a string representation of an object, with various
variables such as Lastname, Age and Marital status

thanks

Portroe
 
* portroe said:
How Do i override the method toString()?

Now it should return a string representation of an object, with
various variables such as Lastname, Age and Marital status

\\\
Public Overrides Function ToString() As String
Return _
m_LastName & ", " & _
m_Age.ToString() & ", " & _
m_Married.ToString()
End Function
///
 
Public Class MyTest
Dim name As String = "Your Name"

Public Overrides Function ToString() As String
Return name
End Function

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top