Hi guys,

I'm really stuck on this. I am not completely familiar with getters and setters so I am having great trouble with this.

Firstly, I am using a windows form application and I have initialised a list within the 'Form1' class. I want to be able to use that list throughout the whole project- so access the contents of the list in my other 3 classes. I've tried making the list Public and I've also tried writing a get / set method, which is shown below- but it still does not work. Any help with this would be greatly appreciated. Thank you

public List<string> StageManagementList
                return stageManagementList;
                stageManagementList = value;


public List<string> StageManagementList {get;set;}

With the method you're showing, you would need a private stageManagementList declared right above that to support it.

...but, yes, that would eventually work.

Edited 4 Years Ago by thines01: formatting

private List<string> list = new List<string>();
public List<string> List
get { return list; }
set { list = value; }

Please use the one that simply does "get;set;" if you can. Then you don't have to declare a ton of extra variables (.NET 3.5 and up supports this)

This question has already been answered. Start a new discussion instead.