473,387 Members | 1,779 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,387 software developers and data experts.

Method returning a two dimensional array

I have the following method:

Expand|Select|Wrap|Line Numbers
  1. public string[,] StringConvert_tblVFWPost(DataTable dt1)
  2.             {
  3.                 string[,] stringArray = new string[dt1.Rows.Count, dt1.Columns.Count];
  4.  
  5.                 for(int row = 0; row < dt1.Rows.Count; ++row)
  6.                 {
  7.                     for(int col = 0; col < dt1.Columns.Count; col++)
  8.                     {
  9.                     stringArray[row, col] = dt1.Rows[row][col].ToString();
  10.                     }
  11.                     return stringArray;
  12.                 }
  13.             }
  14.  
The error I'm getting is "Cannot implicitly convert type 'string[*,*]' to 'string'". So that tells me what the issue is. However, I'm not sure how to fix it.

How do I change this method, so that it properly returns my two dimensional array?
Aug 21 '13 #1
3 13124
weaknessforcats
9,208 Expert Mod 8TB
You cannot return an array from a function because an array is not a type. It is a collection of a type.

All you can return from a function is a type or a pointer to a type.

Read this: http://bytes.com/topic/c/insights/77...rrays-revealed
Aug 22 '13 #2
I should stated that this code is in C#. In C#, pointers are only allowed in unsafe mode. I would like to avoid that. Surely, there's a way I can return an array without a pointer in C#?
Aug 22 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
Return an object with the array as a data member.
Aug 22 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Parrot | last post by:
I am trying to program a function to return a 2 dimensional array, but it's not working. I reduced the return value to 1 dimension and tested that to make sure that the problem wasn't elsewhere. ...
18
by: bsder | last post by:
Hi, Can anyone please tell me how to calculate the size of the following 4-dimensional array, and now to use qsort for sorting on this array? double sp = { 4.0, 5.0, 6.0 }; double spa = { {...
3
by: SQLScott | last post by:
I have looked all over and I cannot find an example or information on passing a multi-dimensional array. Well, that is not true. I found a close example in C++ but it didn't work when I...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
7
by: ashu | last post by:
look at code #include<stdio.h> int *mult(void); int main(void) { int *ptr,i; ptr=mult; for(i=0;i<6;i++) { printf("%d",*(ptr++));
5
by: Martin Pöpping | last post by:
Hello, I want to iterate the second dimension of a 2-dim-array. Let´s say I have an array: double myArray and a given index: int i. Assume my index is given in want to iterate my array...
2
by: amit sinha | last post by:
i need to a method where i add elements in array list and the method should be returning type..
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
3
by: sreemati | last post by:
Hi Everyone, I have a store procedure returning 7 rows for 3 columns, basically I am retrieving: Descriptor Lower Range Upper Range D1 1 10 D2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.