开发者

How to use Settings for Specific User

开发者 https://www.devze.com 2023-04-13 06:02 出处:网络
Using Settings in C# we can assign a Set of Settings like ,Name ,Location ,Size etc. using Visual Studio and chose at which Scope it should be (Application/User).

Using Settings in C# we can assign a Set of Settings like ,Name ,Location ,Size etc. using Visual Studio and chose at which Scope it should be (Application/User).

My Question is ,can i use a Set of Settings separately for each user . Like i would Save User's like User1,User2,User3 where every user have sam开发者_JAVA百科e Attributes like Name ,Surname , Department .

So using Settings is it possible to save Name ,Surname and Department for User1 than the same thing for User2 .

Or is it better to create an Object User with those Fields/Properties and Serialize/Deserialize into XML .

Note : Attributes in this question are just Examples .


  • Option 1 : As you've mentioned, you could serialize your objects like here (http://www.codeproject.com/KB/XML/xml_serializationasp.aspx)

    Note : That article is old, you probably don't want to use the ArrayList.

  • Option 2 (Recommended): You could use your own custom type with Application Settings : Custom type application settings in ASP.NET

    Referring to the linked question, you could do this:

    public class MyUser
    {
       public string Name { get; set; }
       public string Surname { get; set; }
       public int Age { get; set; }
    }
    public class UserCollection : Collection<MyUser>
    {
    }
    


I might be wrong but it looks like you're trying to use Application Settings as data storage. You should consider using database for storing data (MSSQL Server CE for example)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号