Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
int[,] intArray=new string[dataGridView1.Rows.Count,dataGridView1.Columns.Count];

--------where dataGridView1.rows=5048576 and columns.count=21

--------i want to convert intArray to string array.

string[,] stringArray=???(how to convert above intArray?????
Posted

Try something like
stringArray = s1.Select(n => Convert.ToString(n)).ToArray();
 
Share this answer
 
Comments
Santhosh Kumar Jayaraman 6-Sep-12 2:02am    
+5. but inside lambda expression you can just say n.ToString() instead of convert.ToString(n)
Abhinav S 6-Sep-12 4:10am    
Convert.ToString is always a better option. In case n is null, tostring will throw an error.
Santhosh Kumar Jayaraman 6-Sep-12 4:25am    
Yes right.But i believe here we are trying to convert an integer tp string, there are no chances of having null as a value unless if its nullable int.
Abhinav S 6-Sep-12 8:08am    
That is correct.
C#
private void TestMethod(int[] intArray)
{
   string[] stringArray =
   Array.ConvertAll<int,string>
   (intArray,new Converter<int,string>
   (ConvertIntToString));

  // string result = string.Join(",", stringArray);
}

private string ConvertIntToString(int intParameter)
{
   return intParameter.ToString();
}



Source:http://gsharper.blogspot.in/2007/04/convert-integer-array-to-string-array.html[^]

or using Extensionmethod
C#
string[] stringArray = intArray.Select(i => i.ToString()).ToArray():
 
Share this answer
 
v2
Comments
ridoy 6-Sep-12 1:55am    
+5..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900