Strings are collections of characters. In a String, we find representations of words, of phrases, any kind of data. String-based functions are available in VB.NET. Many are well-designed.
Split and Join. Suppose a string contains many parts. And you want it to have just one. You must split it, but if you change your mind, you can join it back.SplitJoin
Core. These core functions are some of the most useful and widely used. Having an understanding of them is important. This knowledge carries over to other .NET languages.CompareConcatEqualsFormatInsertLengthRemoveReplaceString ConstructorSubstringToString
String arrays. We manipulate Strings and arrays of Strings in various ways. Strings are often stored in arrays. Both types must be used together.String ArrayReverseString LoopMid
Lower, upper. The .NET Framework provides us with many different ways to change the cases of characters in Strings. We can use these functions or design our own, custom functions.ToLowerToUpper
First letter. We develop an optimized algorithm for uppercasing the first letter in a String. We can alternatively use ToTitleCase.Uppercase FirstToTitleCase
Search. If you need to search your String for a character pattern or a single character, these IndexOf and LastIndexOf functions are ideal. The result of IndexOf may be negative.ContainsIndexOfIndexOfAnyLastIndexOf
Whitespace. Some functions typically are used to handle whitespace characters. These include Trim, TrimStart and TrimEnd. These functions also handle non-whitespace characters.PadLeft, PadRightTrimTrimEnd, TrimStartIsNullOrEmpty, IsNullOrWhiteSpaceNewLineLSet, RSetLTrim, RTrim
Empty. An empty string is not Nothing (or null). Rather it is just a string literal with a length of 0. We can use String.Empty to access an empty string.String.Empty
Ends, starts. Sometimes we need to test String ends and starts. This logic can be written from scratch. But to our relief, we can use the EndsWith and StartsWith functions.StartsWith, EndsWith
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 also convert Lists and arrays.CStrChar Array to StringList to StringString Array to StringString to Byte ArrayString to Integer
ToCharArray. This Function converts an immutable String into a mutable char array. This enables many optimizations and new capabilities.ToCharArray
Select Case. A String instance can be used in a Select Case statement. A logical decision is made based on the String's character data. In other languages, the switch-statement is similar.Select Case, String
Distance. How many edits does it take to get from one String to another? With the Levenshtein distance algorithm, we compute this number. This tells us String similarity.Levenshtein
ROT13. The ROT13 encoding algorithm shifts the letters in the alphabet by 13 places in two directions based on their values. This is a helpful learning exercise.ROT13
Punctuation. We can remove punctuation with a custom method. This handles all punctuation known to the built in Char.IsPunctuation method.Remove Punctuation
Random. With a helpful method from the Path class, we can easily generate random strings. These have limitations, but work for many simple requirements.Random String
HTML encoding. In HTML pages, we must encode characters like < and >. And in urls we must encode chars like spaces. HtmlEncode and UrlEncode are helpful.HtmlEncode
The String type is powerful. But it has limitations. In situations where we can improve performance by mutating an existing string, consider an alternative type like StringBuilder.StringBuilder