c# - How to set up an application level variable in Windows Universal App? -
i have list :
list<string> stationnames = new list<string>() { "first station", "second station" };
and accesible pages of app if possible. how ? set on every 1 of pages, don't think efficient way.
what need public static property.
in 1 of classes, define such:
public class myclass { public static readonly list<string> stationnames = new list<string> { "first station", "second station" }; }
since static properties not associated instance, can access anywhere using:
myclass.stationnames
edit: added readonly modifier list because, panagiotis pointed out below, not allow list modified @ other time. however, if intended behaviour, don't include readonly modifier.
Comments
Post a Comment