i have created a simple class and want to add it to a listbox using the overloaded tostring() method...i've seen this done in about 10 examples, and straight from msdn, but it's not working for me (using a System.Web.UI.WebControls.ListBox)
even with a simple class:
-------------------
| Public Class asdf
| Public Overrides Function ToString() As String
| Return "asdf"
| End Function
| End Class
-------------------
i try to call
-------------------
| lstboxMyListBox.Items.Add(new asdf())
-------------------
or even
-------------------
| cstr(new asdf())
-------------------
and it won't let it compile because:
"Value of Type 'mynamespace.asdf' cannot be converted to 'String'"
i then tried this:
-------------------
| Public Class asdf
| Public Overloads Overrides Property ToString() As String
| Get
| Return "asdf"
| End Get
| Set(ByVal Value As String)
|
| End Set
| End Property
| End Class
-------------------
but i get an error compiling the class because:
"'ToString' conflicts with a function by the same name declared in 'Object'"
any ideas?
mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
even with a simple class:
-------------------
| Public Class asdf
| Public Overrides Function ToString() As String
| Return "asdf"
| End Function
| End Class
-------------------
i try to call
-------------------
| lstboxMyListBox.Items.Add(new asdf())
-------------------
or even
-------------------
| cstr(new asdf())
-------------------
and it won't let it compile because:
"Value of Type 'mynamespace.asdf' cannot be converted to 'String'"
i then tried this:
-------------------
| Public Class asdf
| Public Overloads Overrides Property ToString() As String
| Get
| Return "asdf"
| End Get
| Set(ByVal Value As String)
|
| End Set
| End Property
| End Class
-------------------
but i get an error compiling the class because:
"'ToString' conflicts with a function by the same name declared in 'Object'"
any ideas?
mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu