<p>I build up an array of strings with</p>

<pre><code>string[] parts = string.spilt(" ");
</code></pre>

<p>And get an array with X parts in it, I would like to get a copy of the array of strings starting at element </p>

<pre><code>parts[x-2]
</code></pre>

<p>Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant way to do this in C#?</p>

[{'answer_id': 31023, 'author': 'Ryan Farley', 'author_id': 1627, 'author_profile': 'https://Stackoverflow.com/users/1627', 'pm_score': -1, 'selected': False, 'text': '<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.array.copy(VS.80).aspx" rel="nofollow noreferrer">Array.Copy</a>. It has an overload that does what you need:  </p>\n\n<blockquote>\n  <p>Array.Copy (Array, Int32, Array,\n  Int32, Int32)<br>\n  <em>Copies a range of elements from an Array starting at the specified source\n  index and pastes them to another Array\n  starting at the specified destination\n  index.</em></p>\n</blockquote>\n'}, {'answer_id': 31025, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': -1, 'selected': False, 'text': '<p><a href="http://msdn.microsoft.com/en-us/library/system.array.copy.aspx" rel="nofollow noreferrer">Array.Copy Method</a></p>\n\n<p>I guess something like:</p>\n\n<pre><code>string[] less = new string[parts.Length - (x - 2)];\nArray.Copy(parts, x - 2, less, 0, less.Length);\n</code></pre>\n\n<p>(<em>sans</em> the off by 1 bug that I\'m sure is in there.)</p>\n'}, {'answer_id': 31027, 'author': 'toolkit', 'author_id': 3295, 'author_profile': 'https://Stackoverflow.com/users/3295', 'pm_score': 3, 'selected': True, 'text': '<p>How about Array.Copy?</p>\n<p><a href="http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx</a></p>\n<blockquote>\n<p>Array.Copy Method (Array, Int32, Array, Int32, Int32)</p>\n<p>Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The length and the indexes are specified as 32-bit integers.</p>\n</blockquote>\n'}, {'answer_id': 354726, 'author': 'joshperry', 'author_id': 30587, 'author_profile': 'https://Stackoverflow.com/users/30587', 'pm_score': 0, 'selected': False, 'text': '<pre><code>List&lt;string&gt; parts = new List&lt;string&gt;(s.Split(" "));\nparts.RemoveRange(0, x - 2);\n</code></pre>\n\n<p>Assuming that <code>List&lt;string&gt;(string[])</code> is optimized to use the existing array as a backing store instead of doing a copy operation this could be faster than doing an array copy.</p>\n'}, {'answer_id': 379719, 'author': 'joshperry', 'author_id': 30587, 'author_profile': 'https://Stackoverflow.com/users/30587', 'pm_score': 3, 'selected': False, 'text': '<p>I remembered answering this question and just learned about a new object that may provide a high performance method of doing what you want.</p>\n\n<p>Take a look at <a href="http://msdn.microsoft.com/en-us/library/1hsbd92d.aspx" rel="nofollow noreferrer"><code>ArraySegment&lt;T&gt;</code></a>.  It will let you do something like.</p>\n\n<pre><code>string[] parts = myString.spilt(" ");\nint idx = parts.Length - 2;\nvar stringView = new ArraySegment&lt;string&gt;(parts, idx, parts.Length - idx);\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/31007', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2723/']