Visual Basic .NET - String Library Function

Length: This function returns the length of the string.

Dim str As String = "Hello, World!"
Dim length As Integer = str.Length 'Output: 13

ToLower: This function converts all the characters in the string to lowercase.

Dim str As String = "HELLO, WORLD!"
Dim lowerCase As String = str.ToLower() 'Output: hello, world!

ToUpper: This function converts all the characters in the string to uppercase.

Dim str As String = "hello, world!"
Dim upperCase As String = str.ToUpper() 'Output: HELLO, WORLD!

Trim: This function removes leading and trailing whitespace characters from the string.

Dim str As String = "   Hello, World!   "
Dim trimmed As String = str.Trim() 'Output: "Hello, World!"

Replace: This function replaces all occurrences of a specified string with another string.

Dim str As String = "The quick brown fox jumps over the lazy dog."
Dim replaced As String = str.Replace("fox", "cat") 'Output: "The quick brown cat jumps over the lazy dog."

Substring: This function returns a substring of the string, starting at a specified index and optionally up to a specified length.

Dim str As String = "Hello, World!"
Dim subStr As String = str.Substring(7) 'Output: "World!"

IndexOf: This function returns the index of the first occurrence of a specified substring in the string.

Dim str As String = "The quick brown fox jumps over the lazy dog."
Dim index As Integer = str.IndexOf("fox") 'Output: 16

LastIndexOf: This function returns the index of the last occurrence of a specified substring in the string.

Dim str As String = "The quick brown fox jumps over the lazy dog."
Dim lastIndex As Integer = str.LastIndexOf("o") 'Output: 29

StartsWith: This function returns a Boolean value indicating whether the string starts with a specified substring.

Dim str As String = "Hello, World!"
Dim startsWith As Boolean = str.StartsWith("Hello") 'Output: True

EndsWith: This function returns a Boolean value indicating whether the string ends with a specified substring.

Dim str As String = "Hello, World!"
Dim endsWith As Boolean = str.EndsWith("World!") 'Output: True

Concat: This function concatenates two or more strings.

Dim str1 As String = "Hello, "
Dim str2 As String = "World!"
Dim result As String = String.Concat(str1, str2) 'Output: "Hello, World!"

Join: This function concatenates an array of strings, using a specified delimiter.

Dim arr() As String = {"The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog."}
Dim result As String = String.Join(" ", arr) 'Output: "The quick brown fox jumps over the lazy dog."

TrimEnd() - Removes all trailing occurrences of a set of characters specified in an array from the end of a string.

Dim str As String = "  Hello World!   "
str = str.TrimEnd(" "c, "!"c) ' "  Hello World"

Split() - This function is used to split a string into an array of substrings based on a specified delimiter. For example:

Dim str As String = "Hello, World!"
Dim substrings As String() = str.Split(",")
' Result: substrings = {"Hello", " World!"}