Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a simple list, like this:

fruitList = new FruitList();

 Apple fruit1 = new Apple("red", "small");
 Banana fruit2 = new Banana("yellow", "big");
 fruitList.AddFruit(fruit1);
 fruitList.AddFruit(fruit2);


My program displays this in a textbox:

textbox.Text = fruitList.DescribeCurrentFruit()

public string DescribeCurrentFruit()
{
    string description;

    if (fruitStock.Count > 0)
    {
        description = fruitStock[fruitCurrentlyDisplayed].Description();
    }
    else
    {
        description = "No Fruits in stock";
    }
    return description;
}


What I have tried:

Currently, the List's two current objects/items (fruit1, fruit2) are automatically loaded as they are a part of my Window Form's load_event. However, if they're not a part of the load_event, or if I want to add more items/objects to the list at runtime, then permanently save them, how can I do so? What is the simplest way of doing so? I'd imagine saving them into the property settings of the project, or XML serialization. But I have no idea where to start. If any further information is needed (I can give you my project/source code), please let me know. I'm desperate! Best regards.
Posted
Comments
an0ther1 17-Dec-17 22:33pm    
Property Settings have 2 scopes, Application & User.
Application scope is read-only but accessible to all users - Visual Studio does not natively support writing to them but you can create custom getters & setters. Problem you may end up running into though is that your User needs to be able to read & write to the location where you store the underlying file, this may fail depending on the level of user - refer; https://msdn.microsoft.com/en-us/library/system.configuration.settingsprovider(v=vs.110).aspx

User scope is read/write but is accessible to the current user only.

First off you need to work out your requirements - if 2 users operate the same machine should they both get access to your updated list?

Kind Regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900