c# - Holding a static int through software reboot -
i building department store management system project. managing range of objects , want have unique ids of them, no 2 objects have same id.
for purpose want hold int symbolizing last id used in program.
i know can't use static int resets when program restarts...
i thought saving disk on shut down seems not elegant me. , wanted ask, there better way store last id in way can use when software reboots?
thank you!
you can use .net settings store variable per appliction or per user.
1) go project properties -> settings , create new lastid variable of type int
2) can use variable code
settings.default.lastid = lastid; settings.default.save();
the saved value available after application restarts
lastid = settings.default.lastid;
Comments
Post a Comment