Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array slicing

Status
Not open for further replies.

flnhst

Programmer
Aug 9, 2005
12
NL
Lets say i have this array of strings:

"foo", "bar", "foo2", "bar2"

How can i 'split' the array, that i have only the items after "bar"?
So i would get this:

"foo2", "bar2"

How is this done? Has C# any form of array slicing (Like in Python)?
 
Take a look at the CopyTo method. It returns a new array that is a copy of the original, but starting at a specified index.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
CopyTo copies the array, but instead of starting at the index of the array at which i want to copy, it places the whole array in the other array starting at specified indexing, no splitting or slicing happens.

Or am i using it wrong?
 
OK, looks I read the docs wrong.
You'll need to write a slice routine, then, that accepts an array and a starting position.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top