views:

73

answers:

1

in my project i have a requirement like "**Set the version to something like 0.0.0.0 if the method cannot get the version from the environment variable**"

and the coding where i need to look is like this array,,any one have idea about this on

string[] sade = new string[6];
 .
 .
 .
 .
  sade [5] = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\secon\secservice", "CurrentVersion", "0").ToString();)
;

any one have idea about coding required here

A: 

You could do something like:

string[] sade = new string[6];
.
.
sade[5] = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\secon\secservice",    "CurrentVersion", "0");
if(sade[5] == null)
{
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\secon\secservice",    "CurrentVersion", "0");
}

That will read the registry and check if it is already defined or not.

samoz
but i need to set in to 0.0.0.0
peter
then change the "0" to "0.0.0.0"
monkey_p
@samoz, the Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\secon\secservice", "CurrentVersion", "0"); line should be Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\secon\secservice", "CurrentVersion", null); or you should compare sade[5] to "0"
monkey_p