views:

167

answers:

4

Hi,

My application is storing contact information. User can edit them through DataGridView and so on. I'm saving those contact info through serializable class which looks like that:

    [Serializable]
public class Contact : INotifyPropertyChanged
{
    private string _fName;
    private string _lName;
    private string _pNumber;

    public event PropertyChangedEventHandler PropertyChanged;

    public Contact(string firstName, string lastName, string phoneNumber, bool fromOutlook){...}

    public Contact(){...}

    public string FirstName{...}
    public string LastName{...}
    public string PhoneNumber{...}

    private void NotifyPropertyChanged(string name){...}
}

But I'm affraid it's not the most efficient / neat format (if I just serialize the class). Does anyone had similar task and solved it in a better manner?

+1  A: 

there are a number of relatively standard formats for address book entries (vCard comes to mind); serializing to one of them is probably your best bet if you're dead set against using a database.

DDaviesBrackett
+1  A: 

If you're certain your app is the only one that will need to consume these serialized classes, the BinaryFormatter serializer will store them quite compactly. If you may have other software utilities that would benefit from reading / writing these things, I would suggest you dump them as XML, either with the SoapFormatter or the XML Serializer.

GWLlosa
+1  A: 

There's nothing wrong with using Serializable; it's a great way to get an object to and from disk. If you're worried about making the format human-readble, use XmlSerializer instead.

Randolpho
+3  A: 

Hi,

I strongly recommend VCard for following reasons.

1.) Universal protocol for contacts. Makes your data right away consumable with other VCard compatible apps. like MS Outlook.

2.) Can be transferred on mobile phones.

3.) Can be used for synchronization. [check out SyncML Contacts Sync.]

4.) You do not need to write a VCard parser your own. Just check this out here Link Txt: http://www.codeproject.com/KB/dotnet/vCardReader.aspx

5.) Serializable.

this. __curious_geek