Logo

Programming-Idioms

History of Idiom 38 > diff from v51 to v52

Edit summary for version 52 by fernacolo:
[C#] Previous example was wrong.

Version 51

2019-10-14, 12:24:18

Version 52

2019-12-06, 02:29:38

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Illustration

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Illustration
Code
var t = s.Substring(i, j);
Code
var t = s.Substring(i, j - i);
Comments bubble
The first argument is the index of first character in substring. The second argument is the substring length.