{"id":269981,"date":"2015-12-09T16:04:02","date_gmt":"2015-12-09T13:04:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=269981"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=269981","title":{"rendered":"\u0426\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0440\u0435\u0437\u044b \u0438 \u0441\u0434\u0432\u0438\u0433\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439"},"content":{"rendered":"<p>       \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u2014 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 <i><b>n<\/b><\/i> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <i><b>i<\/b><\/i>-\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0438\u043b\u0438 \u0436\u0435, \u043a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 <i><b>i<\/b><\/i>-\u0442\u043e\u0433\u043e \u043f\u043e <i><b>j<\/b><\/i>-\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u041d\u0430 \u044f\u0437\u044b\u043a\u0435 <i>C#<\/i> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <i>Linq<\/i> \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cs\">var selectedItems = items.Skip(i).Take(n).ToArray(); var selectedItems = items.Skip(i).Take(j - i).ToArray(); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <i>Substing<\/i>:<\/p>\n<pre><code class=\"cs\">var target = source.Substing(i, n); var target = source.Substing(i, j - i); var target = source.Substing(i); \/\/ from i to end <\/code><\/pre>\n<p>  \u0427\u0430\u0441\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u044e\u0442 \u0441\u0432\u043e\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0438\u0437-\u0437\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0432\u0435\u0440\u044b \u0438\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <i>\u0441\u0440\u0435\u0437\u043e\u0432 (slices)<\/i>, \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b24\/129\/b82\/b24129b82a9e42fba40fddb01381c2dc.png\" alt=\"image\"\/><a name=\"habracut\"><\/a><br \/>  \u041f\u0443\u0441\u043a\u0430\u0439 \u0434\u0430\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0443\u043a\u0432, \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443. \u041a\u0430\u0436\u0434\u043e\u0439 \u0431\u0443\u043a\u0432\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0439 \u0441\u043b\u0435\u0432\u0430-\u043d\u0430\u043f\u0440\u0430\u0432\u043e (\u043e\u0442 \u0433\u043e\u043b\u043e\u0432\u044b), \u043d\u043e \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u0430-\u043d\u0430\u043b\u0435\u0432\u043e (\u043e\u0442 \u0445\u0432\u043e\u0441\u0442\u0430):<\/p>\n<pre><code class=\"cs\">var bodyLetters = new[] {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'I'}; var headIndexes = new[] { 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 }; var tailIndexes = new[] {-8 , -7 , -6 , -5 , -4 , -3 , -2 , -1 }; <\/code><\/pre>\n<p>  \u0412\u044b\u0431\u043e\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u0433\u043e \u043f\u043e \u0448\u0435\u0441\u0442\u043e\u0439 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<pre><code class=\"cs\">\/\/ \u0445\u0432\u043e\u0441\u0442 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 bodyLetters.Slice(3, 7); \/\/ 'D', 'E', 'F', 'G' bodyLetters.Slice(-5, 7); \/\/ 'D', 'E', 'F', 'G' bodyLetters.Slice(3, -1); \/\/ 'D', 'E', 'F', 'G' bodyLetters.Slice(-5, -1); \/\/ 'D', 'E', 'F', 'G' <\/code><\/pre>\n<p>  \u0425\u0432\u043e\u0441\u0442 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u0438\u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0442\u043e\u0433\u0434\u0430 \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b (5-2 = 3 \u0432\u043c\u0435\u0441\u0442\u043e 5-2+1 = 4)<\/p>\n<p>  \u041d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0432\u0435\u0434\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <i><b>8<\/b><\/i> \u043d\u0435\u0442, \u0430 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0435\u043c\u0443 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430\u0439\u0442\u0438 (\u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 <i>-0<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u043e\u0442 <i>+0<\/i>)? \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0445\u0432\u043e\u0441\u0442\u0430, \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b, \u043b\u0438\u0431\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u044f\u0437\u044b\u043a\u0435 <i>Python<\/i>. <\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0432\u043e\u0441\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0433\u043e\u043b\u043e\u0432\u044b?<\/p>\n<pre><code class=\"cs\">bodyLetters.Slice(7, 3); \/\/ ??? bodyLetters.Slice(-1, -5); \/\/ ??? <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0432\u044b\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0436\u0435 \u0442\u043e\u043b\u0435\u0440\u0430\u043d\u0442\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0445\u0432\u043e\u0441\u0442\u0430 \u0438 \u0433\u043e\u043b\u043e\u0432\u044b \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0431\u044b\u0442\u044c \u043c\u043e\u0436\u0435\u0442, \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435?<\/p>\n<p>  \u0410 \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0445\u0432\u043e\u0441\u0442\u0430 \u0438 \u0433\u043e\u043b\u043e\u0432\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442? \u041f\u043e \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0433\u043e\u043b\u043e\u0432\u0443, \u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0445\u0432\u043e\u0441\u0442, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u0432\u043e\u0441\u0442 \u0438 \u0433\u043e\u043b\u043e\u0432\u0430 \u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435! \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0435. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u043b\u0443\u0447\u0430\u044e \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0445\u0432\u043e\u0441\u0442\u0430?<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c\u2026 \u0427\u0442\u043e \u0435\u0441\u043b\u0438 <b>\u0437\u0430\u043c\u043a\u043d\u0443\u0442\u044c, \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0430\u043c \u043d\u0430 \u0441\u0435\u0431\u044f<\/b>? \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <i><b>7<\/b><\/i> \u0438\u0434\u0451\u0442 \u0441\u043d\u043e\u0432\u0430 <i><b>0<\/b><\/i>, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434, \u0441\u043a\u0430\u0436\u0435\u043c, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <i>6<\/i> \u0438 <i>2<\/i>, \u0442\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <i>&#8216;G&#8217;, &#8216;I&#8217;, &#8216;A&#8217;, &#8216;B&#8217;<\/i>. \u0422\u043e\u0433\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <i>Slice(6, 0) \/\/ &#8216;G&#8217; &#8216;I&#8217;<\/i>, \u0430 \u0437\u0430\u043f\u0438\u0441\u044c <i>Slice(5, 5)<\/i> \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u0443\u044e \u043d\u0430 \u043f\u044f\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432\u043b\u0435\u0432\u043e \u2014 <i>&#8216;F&#8217;, &#8216;G&#8217;, &#8216;I&#8217;, &#8216;A&#8217;, &#8216;B&#8217;, &#8216;C&#8217;, &#8216;D&#8217;, &#8216;E&#8217;<\/i> \u2014 \u0432\u043e\u0442 \u0447\u0443\u0434\u043e! <\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <i>Slice(5, 6)<\/i>, \u043f\u043b\u044e\u0441 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u0441 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, \u0430 \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0432\u044b\u0439\u0434\u0435\u043c \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041a\u0430\u043a \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432\u0441\u0451 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0440\u0435\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 <i>Reverse<\/i> \u0432 \u043f\u043e\u043c\u043e\u0449\u044c. \u041c\u044b \u043d\u0430\u0448\u043b\u0438 \u043e\u0431\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0437\u0430\u0434\u0430\u0447 \u043b\u0438\u0448\u0451\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435\u2026 <\/p>\n<pre><code class=\"cs\">\/\/ \u0445\u0432\u043e\u0441\u0442 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 bodyLetters.Slice(6, 2); \/\/ 'G', 'I', 'A', 'B' bodyLetters.Slice(5, 5); \/\/ 'F', 'G', 'I', 'A', 'B', 'C', 'D', 'E' bodyLetters.Slice(5, 6); \/\/  bodyLetters.Slice(5, 0); \/\/ 'F', 'G', 'I' bodyLetters.Slice(5); \/\/ 'F', 'G', 'I' <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0436, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c! <\/p>\n<pre><code class=\"cs\">        public static IEnumerable&lt;T&gt; Slice&lt;T&gt;(this IEnumerable&lt;T&gt; collection, int head, int tail = 0)         {             var items = collection as T[] ?? collection.ToArray();             var count = items.Count();             head = head &lt; 0 ? count + head : head;             tail = tail &lt; 0 ? count + tail : tail;              if (head &lt; 0 || count - 1 &lt; head) throw new ArgumentOutOfRangeException(&quot;head&quot;);             if (tail &lt; 0 || count - 1 &lt; tail) throw new ArgumentOutOfRangeException(&quot;tail&quot;);              if (head &lt; tail)             {                 foreach (var item in items.Skip(head).Take(tail - head))                 {                     yield return item;                 }             }             else             {                 foreach (var item in items.Skip(head))                 {                     yield return item;                 }                                  foreach (var item in items.Skip(0).Take(tail))                 {                     yield return item;                 }                }         } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0441\u044f \u043d\u0430\u043c <i><b>yield<\/b><\/i>. \u0418 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0430 \u0432\u0430\u043c?<\/p>\n<p>  <b>P.S.<\/b> \u0418 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0451, \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e. \u041c\u0435\u0442\u043e\u0434 <i>Slice<\/i> \u2014 \u044d\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430 \u043c\u043e\u0449\u043d\u043e\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"http:\/\/makeloft.by\/ru\/tools\"><i>Aero Framework<\/i><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u043b\u0438\u0433\u0440\u0430\u043d\u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0438 \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u044d\u0442\u0430 \u043a\u0440\u0430\u0441\u043e\u0442\u0430 \u0432\u0430\u0441 \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u2026 \u041f\u0440\u0430\u0432\u0434\u0430, \u043a\u043e\u0434 <i>Aero Framework<\/i> \u2014 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0436\u0438\u0437\u043d\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u0410 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e <u>\u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0440\u0435\u0437\u044b \u0438 \u0441\u0434\u0432\u0438\u0433\u0438<\/u> \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0437\u0430\u043c\u0430\u043d\u0443\u0445\u0430! \u0418\u0437\u0443\u0447\u0430\u0439\u0442\u0435 <i>Aero Framework<\/i> \u0438 \u0432\u044b \u0435\u0433\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u0435.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/272743\/\"> http:\/\/habrahabr.ru\/post\/272743\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u2014 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 <i><b>n<\/b><\/i> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <i><b>i<\/b><\/i>-\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0438\u043b\u0438 \u0436\u0435, \u043a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 <i><b>i<\/b><\/i>-\u0442\u043e\u0433\u043e \u043f\u043e <i><b>j<\/b><\/i>-\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u041d\u0430 \u044f\u0437\u044b\u043a\u0435 <i>C#<\/i> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <i>Linq<\/i> \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cs\">var selectedItems = items.Skip(i).Take(n).ToArray(); var selectedItems = items.Skip(i).Take(j - i).ToArray(); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <i>Substing<\/i>:<\/p>\n<pre><code class=\"cs\">var target = source.Substing(i, n); var target = source.Substing(i, j - i); var target = source.Substing(i); \/\/ from i to end <\/code><\/pre>\n<p>  \u0427\u0430\u0441\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u044e\u0442 \u0441\u0432\u043e\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0438\u0437-\u0437\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0432\u0435\u0440\u044b \u0438\u043d\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f <i>\u0441\u0440\u0435\u0437\u043e\u0432 (slices)<\/i>, \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b24\/129\/b82\/b24129b82a9e42fba40fddb01381c2dc.png\" alt=\"image\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-269981","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=269981"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/269981\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}