Logo

Programming-Idioms

History of Idiom 46 > diff from v45 to v46

Edit summary for version 46 by nsmryan:
Restored version 44

Version 45

2019-12-02, 21:41:06

Version 46

2019-12-04, 22:57:26

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Illustration

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Illustration
Code
string t = s.Remove(3);
Code
string t = s.Substring(0, 5);
Comments bubble
s cannot be null.

Throws ArgumentOutOfRangeException if length is less than 5.
Comments bubble
s cannot be null.

Throws ArgumentOutOfRangeException if length is less than 5.