Clicker计数器保存/加载重置计数 [英] Clicker counter Save/Load resetting count

查看:70
本文介绍了Clicker计数器保存/加载重置计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我对C#非常陌生并且已经有了一些起伏不定而且我目前陷入困境,经过多个小时的试验和错误后我终于设法获得了保存/加载但是当文件加载并且我尝试继续计数时它将
重置为0并且我不确定如何处理这个(对不起,如果它是一个愚蠢的问题,我只是不能说出我正在寻找的东西)

hello, i'm pretty damn new to C# and have had some ups and downs with it and i'm currently stuck, after many hours of trial and error i finally managed to get a save/load implemented however when the file loads up and i try to continue the count it resets to 0 and i'm unsure how to approach this (sorry if its a stupid question, i just cant word what i'm looking for correctly)

这是我的代码:

推荐答案

count的值将初始化为零每当你实例化一个新的Form1。如果你想在调用Form1之间保留先前的计数值,有几种可能性。

The value of count will be initialised to zero whenever you instantiate a new Form1. If you want to keep the previous value of count between calls to Form1, there are a few possibilities.

- 将计数设为静态。

- Make count static.

- 制作计算Form1的公共属性,然后将其从一个实例保存并将其传递回下一个。

- Make count a public property of Form1, then save it from one instance and pass it back to the next.

- 不要继续创建Form1的新实例。相反,只需创建一个实例并继续显示并隐藏它。

- Don't keep making new instances of Form1. Instead, just create one instance and keep showing and hiding it as appropriate.

最佳选择取决于具体情况。如果您向我们展示您使用Form1的代码,我们可能会提供更好的建议。

The best option will depend on the exact circumstances. If you show us the code where you use Form1, we may be able to give better advice.


这篇关于Clicker计数器保存/加载重置计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆