Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C#

Idiom #46 Extract beginning of string (prefix)

Create the string t consisting of the 5 first characters of the string s.
Make sure that multibyte characters are properly handled.

string t = s.Substring(0, 5);

s cannot be null.

Throws ArgumentOutOfRangeException if length is less than 5.
T : String := S (1 .. 5);

New implementation...