运行一次代码 [英] run once code

查看:70
本文介绍了运行一次代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我还在学习用C#进行编码即时享受它我必须说但是我觉得有时会让人感到困惑!


我想知道如何存储字符串,基本上,当我的程序加载时,(单一形式)它会执行一系列OS注册表检查。现在,我的应用程序的某些部分需要对几件事情进行结果,但我不希望实际的检查。每次运行需要时运行,如何运行一次然后存储值以供以后使用?


这是我运行的检查之一,检查是否为64或32位操作系统。我可以运行一次并存储它的故障并重复使用它吗?


谢谢!

展开 | 选择 | Wrap | 行号

解决方案

请注意,很少使用的文件叫做Program.cs ??


把你的价值放在那里,然后他们将在整个程序范围内提供。

展开 | 选择 | Wrap | 行号


嗯......我不是大师,但是如果你把结果存储为字符串或类var?



嗯...我不是一个大师,但如果你把结果存储为字符串或类var怎么办?



我不认为OP对使用什么数据类型感到困惑,所以他可以把它放在哪里,以便应用程序中的任何类都可以访问它


hey guys, im still learning to code in C# im enjoying it i must say but i find it confusing sometimes!

I was wondering how i would go about storing a string, basicly, when my program loads, (single form) it does a series of OS registry checks. now, some parts of my application requite the results for several things, but i dont want to have the actual "checks" run every time its needed, how can i make it run once then store the value for later use?

Here is one of the checks i run, a check to see if its a 64 or 32bit OS. can i have this run once and store its resault and reuse it?


Thanks!

Expand|Select|Wrap|Line Numbers

解决方案

Notice that little used file called Program.cs ??

Put your values in there, and they will be available throughout the scope of your program.

Expand|Select|Wrap|Line Numbers


Hm...I am not a guru, but what if u store the result as a string or as class var?


Hm...I am not a guru, but what if u store the result as a string or as class var?

I don''t think the OP was confused about the what data type to use, so much as where can he put it so any class within the application can access it.


这篇关于运行一次代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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