|
-
Mar 22nd, 2011, 10:54 AM
#1
Thread Starter
Addicted Member
new class with inherits, some properties gone?!
Code:
Public Class Form1
Public Class SearchTask
Inherits List(Of String)
' Fields
Public SearchTerm As String
Public SoundEx As String
Public AdminSettingsHash As Integer
End Class
Public St As New SearchTask
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
St.AdminSettingsHash = 302
St.Add("test1")
St.Add("test2")
St.Add("test3")
St.Add("test4")
St.Add("test5")
MsgBox(St.AdminSettingsHash)
End Sub
End Class
Why is it that if you run this, a message box appears stating '302', but if you check the debugger for the 'St' no property called 'AdminSettingsHash' is listed. Also if you serialize the class, the list of strings are saved, but not the SearchTerm, SoundEx or AdminsettingsHash.
Thanks in advance!
-
Mar 22nd, 2011, 03:20 PM
#2
Re: new class with inherits, some properties gone?!
The class isn't marked serializable, so that could have an issue, depending on what type of serialization you are using. There are plenty of properties that don't show up in the debugger. I'm pretty sure that you can set them that way (I think I did, once), but in your case, it appears that not showing up is all they are doing, since you report that the code is working (other than the serialization). You don't have them as properties anyways. They are member variables as you have it written.
What do you mean by "check the debugger"? That could mean a couple different things, and the specific one you are using may be important.
My usual boring signature: Nothing
 
-
Mar 23rd, 2011, 03:05 AM
#3
Thread Starter
Addicted Member
Re: new class with inherits, some properties gone?!
To make it more clear;
Code:
Imports System.IO
Imports System.Xml.Serialization
Public Class Form1
Public Class SearchTask
Inherits List(Of String)
' Fields
Public SearchTerm As String
Public SoundEx As String
Public AdminSettingsHash As Integer
End Class
Public St As New SearchTask
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
St.AdminSettingsHash = 302
St.SoundEx = "0123"
St.SearchTerm = "yadda"
St.Add("test1")
St.Add("test2")
St.Add("test3")
Dim string_writer As New StringWriter()
Dim serializer As New XmlSerializer(GetType(SearchTask))
serializer.Serialize(string_writer, St)
MsgBox(string_writer.ToString)
End Sub
End Class
Why don't I see 'AdminSettingsHash' etc, in the XML string?
-
Mar 23rd, 2011, 03:07 AM
#4
Thread Starter
Addicted Member
Re: new class with inherits, some properties gone?!
If I remove the 'inherits' from the class, the other options do show up.
Of course I could 'code around it' somehow, but I've rather understand why this is happening. Also, when I debug, I don't see 'adminsettingshash' with the 'st' instance.
-
Mar 23rd, 2011, 08:24 AM
#5
Re: new class with inherits, some properties gone?!
You can give the fields an System.ComponentModel.EditorBrowsable attribute to make them show up in Visual Studio Intellisense:
Code:
<System.ComponentModel.EditorBrowsable(EditorBrowsableState.Always)> _
Public TestField As Object
The EditorBrowsableState argument determines if the field or property will show up in the Intellisense Common tab or Advanced tab. It wouldn't surprise me if something similar applies to using the Serializable attribute, but I don't have much experience with that. BB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|