Array question

  • Thread starter Thread starter Krish
  • Start date Start date
K

Krish

The array in the debugger shows that it has

[0]----value "xxxx" type string


I want to get to the string.


When I do

Array.GetValue(i).ToString(); I get the value

However when I do

String str;

str = Array.GetValue(i)

It tells me type object cannot be converted to string

but why convert the value is of type string anyway.

what is going on - any help appreciated.
 
...
However when I do

String str;

str = Array.GetValue(i)

It tells me type object cannot be converted to string
but why convert the value is of type string anyway.

Becuse the Array doesn't know it's a string, it just knows that it's an
object.

str = (string) Array.GetValue(i)

// Bjorn A
 

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

Back
Top