need to create a custom class called Prefences.cs. I have done some things. Need someone to check it out.

<group name="Preferences">
          <add name="Theme" type="String" allowAnonymous="false"/>
          <add name="Culture" type="String" defaultValue="en-US"/>
        </group>

It will be called Preferences, how should i setup this object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
 
/// <summary>
/// Summary description for Preferences
/// </summary>
[Serializable()]
public class Preferences
{
    public Preferences() { }
    public Preferences
    (
        string theme,
        string culture)
    {
        this.Theme = theme;
        this.Culture = culture;
    }
  
 
    private string theme = string.Empty;
    [SettingsAllowAnonymous(false)]
    public string Theme
    {
        get { return theme; }
        set { theme = value; }
    }
 
    private string culture = "en-US";
    public string Culture
    {
        get { return culture; }
        set { culture = value; }
    }
}

Open in new window

mathieu_cuprykAsked:
Who is Participating?
 
burakiewiczCommented:
with 3.5 you can do it this way you just need to add
using System.Configuration;
[Serializable]
    public class Preferences
    {
        public Preferences() { }
        public Preferences(string theme,string culture)
        {
            this.Theme = theme;
            this.Culture = culture;
        }
        
        [SettingsAllowAnonymous(false)]
        public string Theme { get; set; }
        [DefaultSettingValue("en-US")]
        public string Culture{get;set;}
    }

Open in new window

0
 
burakiewiczCommented:
what version of VS and framework are you using?
0
 
mathieu_cuprykAuthor Commented:
visual 2008 and frame work 3.5
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mathieu_cuprykAuthor Commented:
how come the get and set are like this?
0
 
mathieu_cuprykAuthor Commented:
for the namespace configuration  this is for  [DefaultSettingValue("en-US")]

0
 
mathieu_cuprykAuthor Commented:
can u help me with this question aswell.
0
 
burakiewiczCommented:
the get and set are like that because with the 3.5 you dont need to declare the members the compiler will generate those for you.shorter for developers
0
 
mathieu_cuprykAuthor Commented:
0
 
mathieu_cuprykAuthor Commented:
there is another question related i have not seen anyone able to answer this?
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24146900.html
0
 
burakiewiczCommented:
ok give me a little bit and i can look at both of them
0
 
mathieu_cuprykAuthor Commented:
i would appreciate your opinion. it seems u know what you are doing.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.