Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,851 questions

51,772 answers

573 users

How to create a string from one row of a two-dimensional character array in VB.NET

3 Answers

0 votes
Imports System
Imports System.Text

Public Class CreateStringFromOneRow
    Public Shared Sub Main()
        Dim array As Char(,) = {
        	{"a"c, "a"c, "a"c, "a"c, "a"c},
        	{"b"c, "b"c, "b"c, "b"c, "b"c},
        	{"c"c, "c"c, "c"c, "c"c, "c"c}}
        Dim sb As StringBuilder = New StringBuilder()
        Dim len As Integer = array.GetLength(1)

        For i As Integer = 0 To len - 1
            sb.Append(array(1, i))
        Next

        Dim result As String = sb.ToString()
	
        Console.WriteLine("The string is: " & result)
    End Sub
End Class



' run:
'
' The string is: bbbbb
'

 



answered Feb 7, 2025 by avibootz
0 votes
Imports System
Imports System.Text

Public Class CreateStringFromOneRow
    Public Shared Sub Main()
        Dim jaggedArray As Char()() = New Char(2)() {}
        	jaggedArray(0) = New Char() {"V"c, "B"c}
        	jaggedArray(1) = New Char() {"p"c, "r"c, "o"c, "g"c, "r"c, "a"c, "m"c, "m"c, "i"c, "n"c, "g"c}
        	jaggedArray(2) = New Char() {"l"c, "a"c, "n"c, "g"c, "u"c, "a"c, "g"c, "e"c}
        Dim sb As StringBuilder = New StringBuilder()

        For Each ch As Char In jaggedArray(1)
            sb.Append(ch)
        Next

        Dim result As String = sb.ToString()
	
        Console.WriteLine("The string is: " & result)
    End Sub
End Class



' run:
'
' The string is: programming
'

 



answered Feb 7, 2025 by avibootz
0 votes
Imports System

Public Class CreateStringFromOneRow
    Public Shared Sub Main()
        Dim array As Char(,) = {
        	{"a"c, "a"c, "a"c, "a"c, "a"c},
        	{"b"c, "b"c, "b"c, "b"c, "b"c},
        	{"c"c, "c"c, "c"c, "c"c, "c"c}}
        Dim rowArray As Char() = New Char(array.GetLength(1) - 1) {}
        Dim len As Integer = array.GetLength(1)

        For i As Integer = 0 To len - 1
            rowArray(i) = array(1, i)
        Next

        Dim result As String = New String(rowArray)
	
        Console.WriteLine("The string is: " & result)
    End Sub
End Class



' run:
'
' The string is: bbbbb
'

 



answered Feb 7, 2025 by avibootz
...