two dimesional array

D

Denny

This is probably an easy question but I can't figure it out.

I have a component that returns a 2 dimensional array of strings ( I don't
have access to the source code). I also don't know what the dimensions will
be.

When I try to assign it to another variable I get:

"Cant' explicitly convert type 'string' to 'string[*,*]

I've even tried to declare a string array with know dimensions but no luck.
Anyone have a thought to the solution?

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Denny,

You can call the static GetUpperBound method of the Array class to get
the upper bound for any dimension in the array.

If you don't trust the lower bound, you can call the static
GetLowerBound function to get the lower bound of the array.
 
S

Stanimir Stoyanov

In addition to what Nicholas wrote, the array definition would be

string[,] array = YourClass.MethodWhichReturnsTheArray();
 
J

\Ji Zhou [MSFT]\

Hello Denny,

Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
[MSFT] and I will be working on this issue with you.

As Peter indicates, the error message you post means that the returned type
of the called function is string, not a string array. So, would you like to
elaborate the exact scenario you are facing? We then can give some
suggestions or help on the issue.

If the component you mentioned is a dot net assembly, you can use the tool
Reflector to see all function's signature and IL disassembly codes. Then
you will know what type of data is returned from the called function. You
can download the Reflector here
http://www.red-gate.com/products/reflector/.

Please let me know if you need any future help on this. I am glad to be of
future help. Have a good day, Denny!


Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Denny

Thanks for all the replies. I was able to look at the source code (its from
another department), and we changed it on the component end.

Basically, since it was a VB.net component, with explicit off, the compiler
was automatically changing it to what it thought needed to be returned. We
correctly returned the 2 dimentional array, and the problem was fixed.
 

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

Similar Threads


Top