Convert an Object to an array of strings.

  • Thread starter Thread starter james
  • Start date Start date
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.
 
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());
 
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.
 
Back
Top