Convert an Object to an array of strings.

J

james

I wrote values to the registry in a "MultiString" registry type. I now want
to retrieve these into a string array.
I use this:

String[] LoadedObject = SUBKEY.GetValue(KeyNames.ToString())

but this gives an error "Cannot implicitly convert type 'object' to
'string[]'. Which is fine, but what do I do?

Googling, I saw this:

= (string[])<object>.ToArray(typeof(string));

but my object (the getvalue) bit doesn't seem to offer "ToArray".

James.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cast the value that you get back to the actual data type. If the object
really is a string array, cast it as such:

string[] LoadedObject = (string[])SUBKEY.GetValue(KeyNames.ToString());
 
J

james

Göran Andersson said:
Cast the value that you get back to the actual data type. If the object
really is a string array, cast it as such:

string[] LoadedObject = (string[])SUBKEY.GetValue(KeyNames.ToString());


That worked a treat - I was obviously over complicating it!

James.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top