Changing a default property's value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a string which has been assigned the value of "OneTwoThree". I have
created a property because I want to be able to assign a new value to this
string.

I have:

string numbers = "OneTwoThree";

public string StringToCompare
{
get
{
return numbers;
}
set
{
numbers = value;
}
}

Obviously, this doesn't work.

My program will start up automatically when the user opens their PC and
won't give them the opportunity to set the value of numbers straight away.
Instead, they will have to enter the string "OneTwoThree" to make the form
visible and enable them to change it's value.

Is there a way to accomplish this?
 
I don't understand your question.. why wont the property work? Are you
saying you want to use a property to show a Form, but you wont get the
oppurtunity becasue your program will start automatically on PC boot.. I am
confused

VJ
 
My application will start invisibly when the user starts their PC. It will
have a default key value of "OneTwoThree", and entering this key sequence
will make the form visible and editable. I then want to offer the user the
chance to change the key to a string of their choice.
 
Store the new value in the registry. Then, when the application starts,
ignore the key sequences until you check the registry. If no entry exists
in the registry, begin responding to the default value. If a value exists
in the registry, store that value in your property and begin responding to
the sequences. Here it is in psuedo code:

public MyApp() // this is your constructor or a method called by your
constructor.
{
string newKeySequence = checkRegistryForValue();
if (newKeySequence != null)
{
StringToCompare = newKeySequence;
}
}

HTH

Dale Preston
MCAD, MCDBA, MCSE
 
My program will start up automatically when the user opens their PC and
won't give them the opportunity to set the value of numbers straight away.
Instead, they will have to enter the string "OneTwoThree" to make the form
visible and enable them to change it's value.

You should initialise all fields that need non-default values in the
constructor of your class.

Joanna
 
Back
Top