What is the best way to store static data in C# that will never change

Posted by Luke101 on Stack Overflow See other posts from Stack Overflow or by Luke101
Published on 2010-05-25T18:08:02Z Indexed on 2010/05/26 4:31 UTC
Read the original article Hit count: 186

Filed under:
|

I have a class that stores data in asp.net c# application that never changes. I really don't want to put this data in the database - I would like it to stay in the application. Here is my way to store data in the application:

public class PostVoteTypeFunctions
{
    private List<PostVoteType> postVotes = new List<PostVoteType>();
    public PostVoteTypeFunctions()
    {
        PostVoteType upvote = new PostVoteType();
        upvote.ID = 0;
        upvote.Name = "UpVote";
        upvote.PointValue = PostVotePointValue.UpVote;
        postVotes.Add(upvote);

        PostVoteType downvote = new PostVoteType();
        downvote.ID = 1;
        downvote.Name = "DownVote";
        downvote.PointValue = PostVotePointValue.DownVote;
        postVotes.Add(downvote);

        PostVoteType selectanswer = new PostVoteType();
        selectanswer.ID = 2;
        selectanswer.Name = "SelectAnswer";
        selectanswer.PointValue = PostVotePointValue.SelectAnswer;
        postVotes.Add(selectanswer);

        PostVoteType favorite = new PostVoteType();
        favorite.ID = 3;
        favorite.Name = "Favorite";
        favorite.PointValue = PostVotePointValue.Favorite;
        postVotes.Add(favorite);

        PostVoteType offensive = new PostVoteType();
        offensive.ID = 4;
        offensive.Name = "Offensive";
        offensive.PointValue = PostVotePointValue.Offensive;
        postVotes.Add(offensive);

        PostVoteType spam = new PostVoteType();
        spam.ID = 0;
        spam.Name = "Spam";
        spam.PointValue = PostVotePointValue.Spam;
        postVotes.Add(spam);
    }
}

When the constructor is called the code above is ran. I have some functions that can query the data above too. But is this the best way to store information in asp.net? if not what would you recommend?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc