Logo

Programming-Idioms

History of Idiom 63 > diff from v52 to v53

Edit summary for version 53 by zqwnvl:
[VB] Explicit type

Version 52

2021-08-19, 06:38:09

Version 53

2021-08-19, 06:38:33

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Variables
x2,x,y,z
Variables
x2,x,y,z
Extra Keywords
substring substitute
Extra Keywords
substring substitute
Imports
Imports System
Imports
Imports System
Code
Dim x2 = x.Replace(y, z, StringComparison.Ordinal)
Code
Dim x2 As String = x.Replace(y, z, StringComparison.Ordinal)
Comments bubble
It is best practice to explicitly specify the string comparison method when working with strings in .NET.
Comments bubble
It is best practice to explicitly specify the string comparison method when working with strings in .NET.
Doc URL
https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
Doc URL
https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
Origin
https://docs.microsoft.com/en-us/dotnet/api/system.string.replace
Origin
https://docs.microsoft.com/en-us/dotnet/api/system.string.replace
Demo URL
https://sharplab.io/#gist:1d91331e52756c25ebaac1d01d9b8d53
Demo URL
https://sharplab.io/#gist:1d91331e52756c25ebaac1d01d9b8d53