Serialization and Deserialization

Serialization is a process of converting an object into a stream of data, to easily transfer over the network or to save to disk.   So, using this concept of serialization, we can serialize any object to XML string.
Here is a person class that we can serialize.

Here is the code that takes the person object into string of xml format.

Using Serialization in .NET is provided by the System.Runtim.Serialization name space.

Once you have the XML string, now you can save it to disk, store it into database, or transfer over the network.
Here is the deserialization method that takes serialized string of XML into the person object.

Kyoungsu Do
Software Quality Engineer
ImageSource, Inc. 


Why Is My Combobox So Slow When Databinding?

While working on a project for ImageSource, I recently found an interesting quirk when using the .NET Windows form combobox control.  The issue occurred when I was populating the combobox’s item list with a datasource.  The data was populating at a very slow rate, slower than it was taking to retrieve the data I was using to populate it from the database.  The code I was using looked something like this:

Dim tbl As DataTable = _dataSource.ReadAllItemsFromDbTable()
cboComboBox.DataSource = tbl
cboComboBox.DisplayMember = "Name"
cboComboBox.ValueMember = "Value"

What I later found out was that the ordering of the above code made all the difference, and that by setting the DisplayMember property after setting the DataSource property, I was causing the combobox to reload all of the item data a second time.  To stop it from doubling all of the work, I just had to make a simple code change.  This involved moving the setting of the DisplayMember and ValueMember properties above the setting of the DataSource property.

Dim tbl As DataTable = _dataSource.ReadAllItemsFromDbTable()cboComboBox.DisplayMember = "Name"
cboComboBox.ValueMember = "Value"
cboComboBox.DataSource = tbl

This fixed the issue, as the DisplayMember property is now already set before all of the items are loaded.  I hope this helps fix any issue you may have had with this control.