Logo

Programming-Idioms

History of Idiom 46 > diff from v27 to v28

Edit summary for version 28 by :
New Csharp implementation by user [zehberk]

Version 27

2016-02-16, 16:57:16

Version 28

2016-02-16, 17:21:02

Idiom #46 Extract beginning of string (prefix)

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

Idiom #46 Extract beginning of string (prefix)

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

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

Throws ArgumentOutOfRangeException if length is less than 5.