Re: Convert an Object to an array of strings.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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[i].ToString());

james wrote:
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[i].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.


.



Relevant Pages

  • Re: Convert an Object to an array of strings.
    ... really is a string array, cast it as such: ... That worked a treat - I was obviously over complicating it! ... James. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: mySqlBytes.buffer is getting converted to BigEndian even though both SQL server 2005 and the CLR
    ... The behavior the OP claims to observe is that the cast, not BitConverter, is ... convert a data type from its original data type and back again, ... It is the BitConverter class that 'knows' to return the bytes for an int ... server 2005 and the CLR function are on the same machine which shows ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: casting const away
    ... James Kuyper wrote: ... I don't consider it a lie to the compiler ... If you have an agreement with him that goes beyond the writing of code ... The use of a cast should ...
    (comp.lang.c)
  • Re: Decimal Arithmetic
    ... James J. Weinkam wrote in message ... ... >>> data type. ... >has a true INTEGER data type, the following is true of any INTEGER expression: ...
    (comp.lang.pl1)
  • Re: Passing Timestamp value to sql server
    ... the following example cast the timestamp to a data type of datetime: ... You can also cast it to another type. ... >I still need to pass the value back to the server. ...
    (microsoft.public.access.adp.sqlserver)