Sei sulla pagina 1di 5

VB.

NET String
Array Class Collections File String Console Data Enum Interface Lambda Loop Number Process Property Regex Sort StringBuilder Structure Sub Time Windows

Strings store collections of characters. There are many different functions you can use on Strings in the VB.NET programming language. This selection of content details the String-based functions in this language.

Example
To start, this program demonstrates several concepts: how to declare and initialize a String; how to use a String literal such as "dot"; and how to concatenate strings with the plus operator and with the String.Concat method.
Program that uses String [VB.NET] Module Module1 Sub Main() Dim value As String = "dot" value = value + "net" Dim result As String = String.Concat(value, "perls") Console.WriteLine(result) End Sub End Module Output dotnetperls

Core functions. These functions and subroutines are some of the most useful and widely used in the VB.NET language. Having an understanding of them is important for beginning VB.NET developers. This knowledge will carry over to other .NET languages as well. Equals Format Insert Length Remove Replace String Constructor Substring ToCharArray

ToString Manipulate strings. These examples manipulate Strings and arrays of Strings in various ways. Strings are often stored in arrays. String Array Reverse String Loop Mid

Upper and lower


The .NET Framework provides us with many different ways to change the cases of characters in Strings. With the VB.NET language, we can use these functions or design our own, custom functions. ToLower ToUpper Uppercase First Letter: String ToTitleCase Function

Split and Join

Some of the more popular String functions in the VB.NET language include the Split and Join methods. We provide examples in the following tutorials. Split Join

Search

If you need to search your String for a character pattern or a single character, these IndexOf and LastIndexOf functions are ideal. Contains IndexOf IndexOfAny LastIndexOf LastIndexOfAny

Whitespace

Some functions on the string type typically are used to handle whitespace characters; these functions include the Trim function and its variants TrimStart and TrimEnd. Trim TrimEnd TrimStart NewLine LSet and RSet LTrim and RTrim

Ends and starts

Sometimes you need to see if one String ends with another String, or if one String starts with another String. To our relief, we can use the EndsWith and StartsWith functions. EndsWith StartsWith

ROT13

The ROT13 encoding algorithm is a clever method that shifts the letters in the alphabet by 13 places in two directions based on their values. It is easily reversed. We present a complete implementation in the VB.NET language. ROT13

Convert

It is often necessary to convert Strings to other types, such as Integers. Conversely, most types can be converted to Strings with ToString. We examine String conversions. CStr Char Array to String List to String String Array to String String to Integer

Select Case

A String instance can be used in a Select Case statement in the VB.NET language. A logical decision is made based on the String's character data. Select Case

Summary

The String type in the VB.NET language is powerful, but also has some limitations. In situations where you can improve performance by mutating an existing string, you will need to use an alternative type such as StringBuilder. Note: Strings in the VB.NET language cannot be changed after they are created.

.NET

Potrebbero piacerti anche