473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Convert an Object to an array of strings.

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.
Jul 3 '06 #1
2 22160
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.

Jul 3 '06 #2

"Göran Andersson" <gu***@guffa.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
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());
That worked a treat - I was obviously over complicating it!

James.
Jul 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roger Bonine | last post by:
This might be a stupid question, but I'd appreciate any help you could offer. I'm trying to pass an array of objects back to a Web service. The Web service expects this: Dim Recipients() as...
7
by: Brian P | last post by:
I am getting an invalid cast exception when I try to take an ArrayList with datetime values and use the ToArray method to create an object array. I need to use an object array becase I'm working...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
2
by: Niklas | last post by:
Hi I'm creating a .NET dll, which I will use in VB 6. I have no problem declaring methods, which will take a single Object, String, Integer and so on as a parameter. I manage even to transfer...
0
by: Roger Bonine | last post by:
This might be a stupid question, but I'd appreciate any help you could offer. I'm trying to pass an array of objects back to a Web service. The Web service expects this: Dim Recipients() as...
3
by: Usarian Skiff | last post by:
I'm making a csv file from a datatable. Here's my code 'Copy Headers Dim obj(8) As Object Dim txt As String obj = dt.DefaultView.Item(0).Row.ItemArray txt = Join(obj, ",") filedata = txt ...
5
by: tienlx | last post by:
Hi all, I'm have a problem that i don't know how to convert object to char in C# . Does anybody know ? Thanks.
4
by: kin | last post by:
After a I read Walkthrough: Connecting to Data in Objects (http://msdn2.microsoft.com/en-us/library/ms171892.aspx#Mtps_DropDownFilterText). I still have project on that. My School project...
2
by: jay1_z | last post by:
Here is my code in VB: Return Me.Document.GetItemValue("Subject")(0) The "GetItemValue" method returns an 'object' array, and the first item in the array is a string. This works for me in VB...
2
by: David | last post by:
Hey can anyone help me convert a javascript array into a ruby array. Ive been struggling with this since friday to no avail. This is the function with the ajax.request call that is supposed to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.