phillip Posted February 15, 2005 Posted February 15, 2005 How do i convert the contents of an array to a string. (see below) Array 1 2 3 4 5 To string "1,2,3,4,5" The array could be bigger than 5 Quote phillip Restall
Talyrond Posted February 15, 2005 Posted February 15, 2005 One of I'm sure many ways! Dim myArray() As Integer = {1, 2, 3, 4, 5} Dim myStrinbuilder As New StringBuilder Dim myString As String For counter As Integer = 0 To myArray.GetUpperBound(0) myStrinbuilder.Append(myArray(counter)) myStrinbuilder.Append(",") Next myString = myStrinbuilder.ToString Quote
twistedm1nd Posted February 16, 2005 Posted February 16, 2005 //C# int[] myIntArray = new int[5] { 1, 2, 3, 4, 5 }; Array myArray= myIntArray; string str=""; foreach(int i in myArray) { str += i.ToString()+","; } Console.WriteLine( str); Assuming that you wanted to make use of the Array Class otherwise use the myIntArray in the foreach loop foreach(int i in myIntArray ) Quote
phillip Posted February 16, 2005 Author Posted February 16, 2005 Assuming that you wanted to make use of the Array Class otherwise use the myIntArray in the foreach loop Thanks Guys, I'll give it a try Quote phillip Restall
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.