473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

how to setup static variable at program load

19
Hello,

I'd like to setup a static variable at program load, depending on data saved in a text file.

It's currently hardcoded :
internal static int ApplicationVersion=3;
And I use it to declare my arrays of objects,... :
internal Button[,] ButtonDays = new Button[ApplicationVersion, 7];

How can I update the "ApplicationVersion" once at the startup of the program, so that the whole declarations are also setup accordingly ?

Thank you
Oct 5 '10 #1
2 1461
GaryTexmo
1,501 Expert 1GB
All you need to do is set your ApplicationVersion before you do your declarations. If you did it in your constructor for your main form, you could always do...

Expand|Select|Wrap|Line Numbers
  1. internal static int ApplicationVersion = -1;
  2.  
  3. public MyObject()
  4. {
  5.   if (ApplicationVerson == -1)
  6.     ApplicationVersion = GetApplicationVersion();
  7.  
  8.   SetUpObjects(ApplicationVersion);
  9. }
Is that what you meant? If you really wanted, you could always throw ApplicationVersion on a global static class and set it in Program.cs before your application is even run.
Oct 5 '10 #2
siilexx
19
Hi
thanks for your help
Oct 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Paul | last post by:
I have an existing application that has been installed and running for several months. I recently made a minor change to this application. When the application is installed on the user machine and...
3
by: Datta Patil | last post by:
Hi , #include<stdio.h> func(static int k) /* point2 : why this is not giving error */ { int i = 10 ; // static int j = &i ; /* point 1: this will give compile time error */ return k; } /*...
6
by: Michael B Allen | last post by:
I want to initialize a static variable to a "random" value like: static void * get_key(struct dnsreq *req) { static uint16_t next_txnid = (uint32_t)req & 0xFFFF; But gcc gives me an error: ...
4
by: Sandeep Singh | last post by:
I m building an application in which I redirect the user to a particular page. In the Page Load event of the that page , I assign a variable some value. Then I call the Button click event on that...
18
by: Jack | last post by:
Thanks.
6
by: junw2000 | last post by:
When I define a static variable, where is the memory allocated for the static variable? Thanks. Jack
6
by: depalau | last post by:
I'm running into some issues on maintaining a static variable across the lifetime of a web service and I was wondering if anyone could help. Background: We have developed a C#/1.1 web service...
2
by: Bruza | last post by:
I am trying to define a class static variable. But the value of the static variable seems to be only defined inside the file that the class is declared. See the code below. When I run "python...
9
by: LamSoft | last post by:
Class B { public B() {} } Class A : B { public static string ABC = "myABC"; public A() {} }
11
by: Jef Driesen | last post by:
I have the following problem in a C project (but that also needs to compile with a C++ compiler). I'm using a virtual function table, that looks like this in the header file: typedef struct...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.