Logo

Programming-Idioms

History of Idiom 46 > diff from v44 to v45

Edit summary for version 45 by asdf:
[C#] asdf

Version 44

2019-10-14, 12:24:48

Version 45

2019-12-02, 21:41:06

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.Substring(0, 5);
Code
string t = s.Remove(3);
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.