What should be the approach for implementing data storing
I would be having variables
Page No
Position
URL
Text
Word
I would be having above for different words i.e for word 1 I may have
Page No =1
Position =10
URL abc.com
Text realtext
Word real
and so on so I have to save them in list.
First I thought of declaring list for each then I thought it is not a good idea.
Is there any way to save them so that I c开发者_开发技巧an access data according to any url?
I do not have to use database. These lists are temporary and will be populated each time program starts.
Create a class with the variables you want as properties:
class Storage
{
public string Url
{
get;
set;
}
//etc.
}
Edit: you can use this class to store your information:
Storage myStorage = new Storage();
myStorage.Url = "www.example.com";
//etc
Then you can store each object you created in a generic Dictionary:
Dictionary<string, Storage> dict = new Dictionary<string, Storage>();
dict.Add(myStorage.Url, myStorage);
Edit: And you can retrieve each object with the url:
Storage fromDict = dict["www.example.com"];
精彩评论