Reading character from String in VB.NET

This blog defines the How to Read character from String in VB.NET. The following code example allows you to read a certain number of characters from an existing string, starting at a specified place in the string. Use StringReader to do this, as demonstrated below.

Example

Imports System.IO

Imports System.Text

Module Module1

    Sub Main()

        Dim count As [String] = "This is a countable character"

        Dim c(20) As Char

        Dim sr As New StringReader(count)

        sr.Read(c, 0, 15)

        Console.WriteLine(b)

        sr.Close()

    End Sub

End Module

Read Method

Read method is used to read the character from String.

sr.Read(c, 10, 15)

c -  defines the char array the size of the source string.

0 - Defines from the first array member.

15 - Read 15 characters into the array that holds the string.

OUTPUT

read1.gif

Figure1