What should I do for saving a custom object in Properties.Settings ?

I have a custom type, for example:

class NewClass

{

  private int _count;

  private string _name;

  public int Count

  {

    get { return _count; }

    set { _count = value; }

  }

  public string Name

  {

      get { return _name; }

      set { _name = value; }

  }

}

I want to save the object of this type in Properties.Settings.

NewClass c = new NewClass();

c.Count = 10;

c.Name = "NewName";

Properties.Settings.Default.NewObject = c;

Properties.Settings.Default.Save();

But it doesn't work.



Answer this question

What should I do for saving a custom object in Properties.Settings ?

  • Beugen

    it works....

    Thanks a lot Mr. J. Stenberg


  • YU_MSVB

    Make the class public. The configuration API will use XML serialization when saving the class, and only public types can be XML serialized.

    Best regards,
    Johan Stenberg



  • What should I do for saving a custom object in Properties.Settings ?