We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

mathieu_cupryk
on
Medium Priority
163 Views
Last Modified: 2012-05-06
<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

Comment
Watch Question

what version of VS and framework are you using?

Author

Commented:
visual 2008 and frame work 3.5
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
how come the get and set are like this?

Author

Commented:
for the namespace configuration  this is for  [DefaultSettingValue("en-US")]

Author

Commented:
can u help me with this question aswell.
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

Author

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
ok give me a little bit and i can look at both of them

Author

Commented:
i would appreciate your opinion. it seems u know what you are doing.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.