Possible duplicate:How to copy part of an array to another array in C #?
if I have:
string[] myArray = . . . .
which is an array with a length of 10. How can I create a new string array, which is the 2-10th elements of the first array without a loop?
Use System.Array.Copy :
string[] myArray = .... string[] copy = new string[10]; Array.Copy(myArray, 2, copy, 0, 10);
Array.Copy
(But mind you, it will loop under the covers, just optimally).
An example .
// Copies the last two elements from the Object array to the Int32 array. Array::Copy( myObjArray, myObjArray->GetUpperBound(0) - 1, myIntArray, myIntArray->GetUpperBound(0) - 1,
: http://msdn.microsoft.com/en-us/library/system.array.copy%28VS.71%29.aspx
Array.Copy(myIntArray, myIntArray.GetLowerBound(0), myObjArray, myObjArray.GetLowerBound(0), 1);
Source: https://habr.com/ru/post/1754175/More articles:WCF: how to connect to a service by IP: port - serviceMediaElement - How to get FPS (frames per second)? - silverlightIs it possible to set the gradient to text color? - htmlRecommend class design in Objective-C - design-patternsRun a function every day at a specific time - .netProblem CGContextSetShadowWithColor - multithreadingCreating Skew AngleY ββfrom a oblique point for a rhomboid in XAML - mathWhere can I change the detailed optimization settings of the C # compiler in Visual Studio? - compiler-optimizationHow to disconnect Visual Studio 2010 JavaScript debugger from script - javascriptAndroid ImageButton with image and text - androidAll Articles