Re: Convert an Object to an array of strings.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC 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: 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)
  • Re: CAST error during FETCH in SQLRPGLE program
    ... C+ LEFT OUTER JOIN ALLOCCAN B ... A character in the argument for the CAST function was not correct. ... Change the result data type to one that recognizes the characters in the CAST argument, or change the argument to contain a valid representation of a value for the result data type. ...
    (comp.sys.ibm.as400.misc)