ExtensionMethod.NET Home of 818 C#, Visual Basic, F# and Javascript extension methods

Right

Returns a string containing a specified number of characters from the right side of a string

Source

<System.Runtime.CompilerServices.Extension()>
Public Function Right(ByVal text As String, size As Integer) As String
    Return text.Substring(Math.Max(0, text.Length - size), Math.Min(text.Length, size))
End Function

Example

Console.WriteLine("Fons".Right(2))

Author: Fons Sonnemans

Submitted on: 18 okt 2016

Language: VB

Type: String

Views: 1680