Link to home
Start Free TrialLog in
Avatar of rgn2121
rgn2121Flag for United States of America

asked on

Help creating a ToString type of method...

I will try to word this correctly.  I know how to create methods for my classes, but not for properties.  For instance, The System.Data.DataTable has a Property called TableName.  The  TableName Property has a number of functions under it, one of which is ToString.  How is that created so that it shows up under TableName?

If I do the following:
Dim table as New System.Data.DataTable
table.TableName.ToString

This will give me the name of the table as a string.  I am trying to implement a ToCSV, that I would like to use for a test app I use to try things out.  I would like to be able to do the following..

Dim table as MyTable
table.Export.ToCSV

I have some skeleton code below...
Any thoughts or comments are much appreciated....

Public Class MyTable
      Inherits System.Data.DataTable
 
sub New
mybase.New()
end sub
 
Public Property Export()
 
End Property
 
Public Function ToCSV() as boolean
 
End Function
 
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgn2121

ASKER

Outstanding!!!, I figured I wasn't describing it as well as I should.  I am curious if you don't mind...if I was to do something like that which you have above, or even just adding a method to the MyTable class called ExportToCSV; how would I know what to export.

If I was able to do
Dim dt As New MyTable
    dt.Export.ToCSV()
Or even simpler
Dim dt As New MyTable
    dt.ExportToCSV()
When ever ExportToCSV is called, how does it know what table to export without me passing that table in?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgn2121

ASKER

That is what I am not sure about...Normally I pass in a destination file path of where it is to be exported and the table to export.

Sub ExportToCSV()

...Some Code

End Sub
Avatar of rgn2121

ASKER

TechTiger007...I am going to open this in a new question since webtubbs answered my previous question.  Please post your previous anser and all subsequent answers there so I can award full points to you both for the answers to my questions.

Thanks...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wettubs nice. I think you win.
Avatar of rgn2121

ASKER

Thanks to all...